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

ENUM and SET values for MySQL #259

Closed
hubg398 opened this issue May 23, 2024 · 4 comments
Closed

ENUM and SET values for MySQL #259

hubg398 opened this issue May 23, 2024 · 4 comments
Assignees

Comments

@hubg398
Copy link

hubg398 commented May 23, 2024

This one is more a feature request, as I don't think the parser supports this yet.

This is for the ENUM column type when the values are specified inline.

Relevant doc for MySQL and example here: https://dev.mysql.com/doc/refman/8.0/en/enum.html

parse_results = DDLParser("""CREATE TABLE shirts (
    name VARCHAR(40),
    size ENUM('x-small', 'small', 'medium', 'large', 'x-large')
);
""", silent=False).run(output_mode='mysql')

print(parse_results)

Gives

DDLParserError: Unknown statement at LexToken(STRING_BASE,"'x-small'",1,58)

Thanks

@hubg398
Copy link
Author

hubg398 commented May 31, 2024

Hey adding this here since it should be in the same part of the parser logic (eg same syntax) as the above, but for SETS

parse_results = DDLParser("""
CREATE TABLE myset (
      randomcolumn SET('a', 'b', 'c', 'd')
);
""", silent=False).run(output_mode='mysql')

Result

Unknown statement at LexToken(STRING_BASE,"'a'",1,32)

Docs: https://dev.mysql.com/doc/refman/8.0/en/set.html

@hubg398 hubg398 changed the title ENUM values for MySQL ENUM and SET values for MySQL May 31, 2024
@rayliverified
Copy link

@xnuinside I've managed to get all the other types working for omymodels.

This is the final blocker. Enums and sets with defaults crash.

cancellation_type enum('enabled','disabled') NOT NULL DEFAULT 'enabled'

ddl_parser.py", line 289, in p_error
    raise DDLParserError(f"Unknown statement at {p}")
simple_ddl_parser.ddl_parser.DDLParserError: Unknown statement at LexToken(NOT,'NOT',1,387)

Would appreciate your help here.

@xnuinside
Copy link
Owner

@rayliverified @hubg398 working on it, will add in 1.6.2 version

@xnuinside
Copy link
Owner

UPD: released in version 1.7.0 https://pypi.org/project/simple-ddl-parser/1.7.0/ tests also added - https://github.com/xnuinside/simple-ddl-parser/pull/287/files#diff-c5dbbef7e9cbb2c64b384079070c3006398036d834774db5983a1e347b7747f8 if will be needed anything else - feel free to open new issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants