Table name which is also a "reserved word" fails to parse
nurih opened this issue · 5 comments
Consider:
create table index (col1:int);
create table foo.[index] (col1:int);
create table foo.index (col1:int);
The first 2 lines understand a table named "index" is intended.
The third line classifies the word "index" as the token 'INDEX' probably here.
Though not a good or recommended practice, table names are allowed to be arbitrary strings, even reserved words.
If strict adherence to quoted/delimited usage of key-word-as-identifier DDL is desired, then the first line (bare "index" ) should have failed.
If relaxed adherence is intended, then all 3 should have succeeded.
@nurih I will fix it in next release, it should not recognise it as INDEX token in this statement. Thanks for opening the issue!
@nurih can you clarify for me about 'col1:int' syntax, what DB support it? did not saw before that column name & type separated by ':'.
About errors - parser works always in silent mode - so it parse everything that can and do not raise errors. Possible in future releases I will add raise error if something cannot be parsed. I created placeholder issue for that - #109
@nurih I added the test for case """create table index (col1 int);
create table foo.[index] (col1 int);
create table foo.index (col1 int);
""" https://github.com/xnuinside/simple-ddl-parser/blob/main/tests/test_simple_ddl_parser.py#L2389 and it works correctly in version 0.24.2 (already released), but syntax (col1:int) is not supported (question upper)
(col1:int)
was a mistake. Should have been (col1 int)
.
Very happy for this quick fix! Thank you!