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
175 stars 40 forks source link

Problems with UNIQUE parsing #236

Closed cfhowes closed 6 months ago

cfhowes commented 6 months ago

There appears to be a couple of problems with UNIQUE parsing.

  1. https://github.com/xnuinside/simple-ddl-parser/blob/f605740c55fcbc3a28cbfc682308fc5a1e1a21fe/tests/test_simple_ddl_parser.py#L365 I believe that this test is incorrect. The output should not have UNIQUE on the individual columns, but rather should have an entry in constraints.uniques with both columns listed in the columns. See https://www.mysqltutorial.org/mysql-basics/mysql-unique-constraint/#:~:text=To%20define%20a%20UNIQUE%C2%A0%20constraint%20for%20two%20or%20more%20columns%2C%20you%20use%20the%20following%20syntax%3A
  2. UNIQUE KEY statements currently cause the entire table to be ignored. IE UNIQUE KEY "fun_unique_key" ("fun_unique_column"), In this case I think we'd like a single column to parse into a column UNIQUE statement, and multiple columns to parse into the constraints.uniques location.