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

Support Parse MYSQL DDL with 'COLLATE' option #265

Closed bumhwan closed 2 months ago

bumhwan commented 3 months ago

Is your feature request related to a problem? Please describe.

Our database tables are set up with collate options, and due to these collate options, we always have to remove them before using simple-ddl-parser. This additional preprocessing step is frustrating and error-prone.

Describe the solution you'd like

There are two potential solutions:

Parse the COLLATE keyword along with other options. If there are unsupported options, instead of failing the entire parsing process, return the successfully parsed keywords and ignore or flag the unsupported ones.

Describe alternatives you've considered

Currently, we are solving this issue by removing the COLLATE clause before feeding the DDL into simple-ddl-parser. However, we would like to eliminate this preprocessing step.

Additional context

Here is an example of a DDL statement that causes issues:

CREATE TABLE example_table (
    id INT PRIMARY KEY,
    name VARCHAR(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

Library Version: 1.5.1 Python Version: 3.10 Operating System: macOS

Updating the parser to handle these MySQL-specific options would greatly improve usability. I appreciate the work put into this library and hope this issue can be resolved soon.

xnuinside commented 2 months ago

merged & released in 1.5.2