andreasgerstmayr / fava-dashboards

Custom Dashboards for Beancount in Fava
MIT License
176 stars 21 forks source link

Default Assets šŸ’° query fails with syntax error #82

Closed AlphaJack closed 3 months ago

AlphaJack commented 3 months ago

Hi, in my system I have:

However, when I open the dashboards plugin, I read the following error:

error processing panel "Assets šŸ’°": failed to execute query SELECT CONVERT(SUM(position), 'EUR') AS value WHERE account ~ '^Assets:': syntax error

I can replicate it from beanquery CLI:

beanquery file.beancount "SELECT CONVERT(SUM(position), 'EUR') AS value WHERE account ~ '^Assets:'"
Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/beanquery/parser/__init__.py", line 61, in parse
    return parser.BQLParser().parse(text, semantics=BQLSemantics())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/tatsu/contexts.py", line 240, in parse
    raise self._furthest_exception
  File "/usr/lib/python3.12/site-packages/tatsu/contexts.py", line 232, in parse
    rule = self._find_rule(start)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/tatsu/parsing.py", line 18, in _find_rule
    self._error(name, exclass=FailedRef)
  File "/usr/lib/python3.12/site-packages/tatsu/contexts.py", line 539, in _error
    raise self._make_exception(item, exclass=exclass)
tatsu.exceptions.FailedRef: (1:1) could not resolve reference to rule 'start' :
SELECT CONVERT(SUM(position), 'EUR') AS value WHERE account ~ '^Assets:'
^

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/bin/beanquery", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/lib/python3.12/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/beanquery/shell.py", line 780, in main
    shell.onecmd(query)
  File "/usr/lib/python3.12/site-packages/beanquery/shell.py", line 266, in onecmd
    return self.execute(line)
           ^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/beanquery/shell.py", line 342, in execute
    statement = self.parse(query, **kwargs)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/beanquery/shell.py", line 372, in parse
    statement = self.context.parse(line)
                ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/beanquery/__init__.py", line 41, in parse
    return parser.parse(query)
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/beanquery/parser/__init__.py", line 65, in parse
    raise ParseError(parseinfo) from exc
beanquery.parser.ParseError: syntax error

Do you have any idea? I just update from dashboard r73, and I didn't have beanquery or tatsu installed before.

andreasgerstmayr commented 3 months ago

Can you try to run this query with the latest beanquery in a new virtual env?

AlphaJack commented 3 months ago

It works, I'll check if TatSu 5.7.4 or other dependencies fix the issue