Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Table name which is also a "reserved word" fails to parse #108

Closed
nurih opened this issue Jan 17, 2022 · 5 comments
Closed

Table name which is also a "reserved word" fails to parse #108

nurih opened this issue Jan 17, 2022 · 5 comments
Labels
bug Something isn't working

Comments

@nurih
Copy link
Contributor

nurih commented Jan 17, 2022

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.

@xnuinside
Copy link
Owner

xnuinside commented Jan 17, 2022

@nurih I will fix it in next release, it should not recognise it as INDEX token in this statement. Thanks for opening the issue!

@xnuinside xnuinside added the bug Something isn't working label Jan 17, 2022
@xnuinside
Copy link
Owner

xnuinside commented Jan 19, 2022

@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

@xnuinside
Copy link
Owner

@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)

@nurih
Copy link
Contributor Author

nurih commented Jan 19, 2022

(col1:int) was a mistake. Should have been (col1 int).

@nurih
Copy link
Contributor Author

nurih commented Jan 19, 2022

Very happy for this quick fix! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants