You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 11, 2021. It is now read-only.
First of all, thank you for nice parser, it helps much of my usecases.
Here I report some glitch with parsing UNION-ed SELECTs containing ORDER BY.
Confirmed in moz-sql-parser=2.42.19034, pyparsing=2.2.0 on Python3.6.5.
Thanks
>>> mozql.parse('select a from b order by a asc')
{'select': {'value': 'a'}, 'from': 'b', 'orderby': {'value': 'a', 'sort': 'asc'}}
>>> mozql.parse('select a from b order by a desc')
{'select': {'value': 'a'}, 'from': 'b', 'orderby': {'value': 'a', 'sort': 'desc'}}
>>> mozql.parse('select a from b union select 2')
{'union': [{'select': {'value': 'a'}, 'from': 'b'}, {'select': {'value': 2}}]}
>>> mozql.parse('select a from b oder by a union select 2')
Traceback (most recent call last):
File "/home/developer/.virtualenvs/3/lib/python3.6/site-packages/moz_sql_parser/__init__.py", line 35, in parse
parse_result = SQLParser.parseString(sql, parseAll=True)
File "/home/developer/.virtualenvs/3/lib/python3.6/site-packages/pyparsing.py", line 1632, in parseString
raise exc
File "/home/developer/.virtualenvs/3/lib/python3.6/site-packages/pyparsing.py", line 1626, in parseString
se._parse( instring, loc )
File "/home/developer/.virtualenvs/3/lib/python3.6/site-packages/pyparsing.py", line 1529, in _parseCache
value = self._parseNoCache(instring, loc, doActions, callPreParse)
File "/home/developer/.virtualenvs/3/lib/python3.6/site-packages/pyparsing.py", line 1379, in _parseNoCache
loc,tokens = self.parseImpl( instring, preloc, doActions )
File "/home/developer/.virtualenvs/3/lib/python3.6/site-packages/pyparsing.py", line 3395, in parseImpl
loc, exprtokens = e._parse( instring, loc, doActions )
File "/home/developer/.virtualenvs/3/lib/python3.6/site-packages/pyparsing.py", line 1529, in _parseCache
value = self._parseNoCache(instring, loc, doActions, callPreParse)
File "/home/developer/.virtualenvs/3/lib/python3.6/site-packages/pyparsing.py", line 1383, in _parseNoCache
loc,tokens = self.parseImpl( instring, preloc, doActions )
File "/home/developer/.virtualenvs/3/lib/python3.6/site-packages/pyparsing.py", line 3183, in parseImpl
raise ParseException(instring, loc, self.errmsg, self)
pyparsing.ParseException: Expected end of text (at char 21), (line:1, col:22)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/developer/.virtualenvs/3/lib/python3.6/site-packages/moz_sql_parser/__init__.py", line 44, in parse
raise ParseException(sql, e.loc, "Expecting one of (" + (", ".join(expecting)) + ")")
pyparsing.ParseException: Expecting one of (join, offset, union all, right outer join, full outer join, left outer join, right join, order by, left join, limit, full join, having, group by, inner join, where) (at char 21), (line:1, col:22)
The text was updated successfully, but these errors were encountered:
After reading the code, I remember: The order by clause must follow any union operations. This goes to improving error reporting. I added a test with the hope it can be made better in the future (509977a)
Hello,
First of all, thank you for nice parser, it helps much of my usecases.
Here I report some glitch with parsing UNION-ed SELECTs containing ORDER BY.
Confirmed in moz-sql-parser=2.42.19034, pyparsing=2.2.0 on Python3.6.5.
Thanks
The text was updated successfully, but these errors were encountered: