xnuinside / simple-ddl-parser

Simple DDL Parser to parse SQL (HQL, TSQL, AWS Redshift, BigQuery, Snowflake and other dialects) ddl files to json/python dict with full information about columns: types, defaults, primary keys, etc. & table properties, types, domains, etc.
MIT License
183 stars 41 forks source link

Unable to parse mysql ddl with table configuration #206

Closed vegetablest closed 5 months ago

vegetablest commented 1 year ago

Describe the bug If the MySQL table creation statement specifies table configuration such as storage engine or character encoding, the content will not be parsed.

To Reproduce 1.Parsed failed

CREATE TABLE `employee` (
  `user_id` int(11) NOT NULL AUTO_INCREMENT,
  `user_name` varchar(50) NOT NULL,
  `authority` int(11) DEFAULT '1' COMMENT 'user auth',
  PRIMARY KEY (`user_id`),
  KEY `FK_authority` (`user_id`,`user_name`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8;

2.Parsed successfully

CREATE TABLE `employee` (
  `user_id` int(11) NOT NULL AUTO_INCREMENT,
  `user_name` varchar(50) NOT NULL,
  `authority` int(11) DEFAULT '1' COMMENT 'user auth',
  PRIMARY KEY (`user_id`),
  KEY `FK_authority` (`user_id`,`user_name`)
);

image

Expected behavior I think both parsing should be able to parse the field information.

Additional context python==3.11 simple-ddl-parser==0.31.0

utkarshkoppikar7 commented 5 months ago

I have noticed the same behaviour, should we have procedure to filter these properties out?

xnuinside commented 5 months ago

Fix was released in version 1.2.1 - https://pypi.org/project/simple-ddl-parser/ https://github.com/xnuinside/simple-ddl-parser/pull/247. @vegetablest thanks for reporting this issue, @utkarshkoppikar7 thanks for comment, it was good push to work on it ) . test was added: https://github.com/xnuinside/simple-ddl-parser/blob/main/tests/dialects/test_mysql.py#L550. thanks one more time! if will be any other issues - feel free to open new one

vegetablest commented 5 months ago

awesome👍