Function names
Closed this issue · 2 comments
rcoup commented
Current underscores aren't supported in function names (eg. ST_MakePoint(...)
)
After writing a test case, the fix looks to be expanding function name
to be ident
rather than Word(alphas)
at sql_parser.py:218
, but then I get a test failure.
ERROR: test_096 (tests.test_format_and_parse.TestFormatAndParse)
...
pyparsing.ParseException: Expected end of text (at char 21), (line:1, col:22)
During handling of the above exception, another exception occurred:
pyparsing.ParseException: Expecting one of () (at char 21), (line:1, col:22)
During handling of the above exception, another exception occurred:
tests.test_format_and_parse.VerificationException:
SQL: SELECT f1 FROM test1 WHERE ('x' || f1) BETWEEN 'x10' AND 'x20' ORDER BY f1
Broken SQL: SELECT f1 FROM test1 WHERE BETWEEN('x' || f1, 'x10', 'x20') ORDER BY f1
JSON:
{'from': 'test1',
'orderby': {'value': 'f1'},
'select': {'value': 'f1'},
'where': {'between': [{'concat': [{'literal': 'x'}, 'f1']},
{'literal': 'x10'},
{'literal': 'x20'}]}}
Broken JSON:
''
In SQLIte at least, SELECT "somefunc"(1,2,3);
works fine, as should schema-qualified functions, etc. (related #95). Maybe ident
is picking up something weird I can't spot?
rcoup commented
Testcase:
def test_function_names(self):
sql = "SELECT ST_AsText(ST_MakePoint(174, -36));"
result = parse(sql)
expected = {
'select': {
'value': {
'st_astext': {
'st_makepoint': [174, -36]
}
}
}
}
self.assertEqual(result, expected)
klahnakoski commented
this will be fixed shortly 4e43e81