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

MYSQL's AUTO INCREMENT not recognized by DDLParser #130

Closed
rheophile10 opened this issue May 26, 2022 · 2 comments
Closed

MYSQL's AUTO INCREMENT not recognized by DDLParser #130

rheophile10 opened this issue May 26, 2022 · 2 comments

Comments

@rheophile10
Copy link


from simple_ddl_parser import DDLParser

ddl = """
CREATE TABLE Users (
   user_id INT NOT NULL AUTO INCREMENT,
   username VARCHAR(100) NOT NULL,
   password VARCHAR(40) NOT NULL,
   submission_date DATE,
   PRIMARY KEY ( user_id )
);
"""

result = DDLParser(ddl).run(output_mode="mysql")
print(result)

output is

[{'primary_key': ['user_id']}]

if we remove AUTO INCREMENT however, input is now


from simple_ddl_parser import DDLParser

ddl = """
CREATE TABLE Users (
   user_id INT NOT NULL,
   username VARCHAR(100) NOT NULL,
   password VARCHAR(40) NOT NULL,
   submission_date DATE,
   PRIMARY KEY ( user_id )
);
"""

result = DDLParser(ddl).run(output_mode="mysql")
print(result)

and output is

[{'columns': [{'name': 'user_id', 'type': 'INT', 'size': None, 'references': None, 'unique': False, 'nullable': False, 'default': None, 'check': None}, {'name': 'username', 'type': 'VARCHAR', 'size': 100, 'references': None, 'unique': False, 'nullable': False, 'default': None, 'check': None}, {'name': 'password', 'type': 'VARCHAR', 'size': 40, 'references': None, 'unique': False, 'nullable': False, 'default': None, 'check': None}, {'name': 'submission_date', 'type': 'DATE', 'size': None, 'references': None, 'unique': False, 'nullable': True, 'default': None, 'check': None}], 'primary_key': ['user_id'], 'alter': {}, 'checks': [], 'index': [], 'partitioned_by': [], 'tablespace': None, 'constraints': {'uniques': None, 'checks': None, 'references': None}, 'schema': None, 'table_name': 'Users'}]```
@xnuinside
Copy link
Owner

@rheophile10 hi! Thanks for great description:) I will try to fix the issue during the weekends

@xnuinside
Copy link
Owner

sorry for the delay, fix released in version 0.26.3 - https://github.com/xnuinside/simple-ddl-parser/blob/main/tests/test_simple_ddl_parser.py#L2698 test added. If will be any new issues - feel free to open new ticket @rheophile10 thank you!

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

2 participants