xnuinside/simple-ddl-parser

CHECK with IN clause does not parse

tomc-goodrx opened this issue · 2 comments

Using the IN keyword in a CHECK causes parsing to fail. For example:

`col_name` varchar(5) CHECK( `col_name` = 'year' OR `col_name` = 'month' ),

Works but with an IN statement doesn't:

`col_name` varchar(5) CHECK( `col_name` IN ('year', 'month') ),

With silent=False we get an error like:

  File ".../lib/python3.9/site-packages/simple_ddl_parser/ddl_parser.py", line 199, in p_error
    raise DDLParserError(f"Unknown statement at {p}")
simple_ddl_parser.ddl_parser.DDLParserError: Unknown statement at LexToken(STRING,"'year'",1,544)

Using OR statements becomes unwieldy when there are more than a handful of options in the enum so it would be nice to support this. Thanks.

@tomc-goodrx thanks for reporting, I'm working now on new version - will add support for IN statement in CHECK.

@tomc-goodrx :( it was hard & long month, sorry for the delay, just released v 0.26.0 that contains fix https://pypi.org/project/simple-ddl-parser/ and test - https://github.com/xnuinside/simple-ddl-parser/blob/main/tests/test_checks.py#L10 if will be any more issues, feel free to open new issue. And sorry for the delay one more time.