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

Parser skips tables containing 'REFERENCES' and 'NOT NULL' #239

Closed Nerwerder closed 4 months ago

Nerwerder commented 5 months ago

Describe the bug

Calling 'parse_from_file' on a file containing (postgres) sql 'create table' instructions will not return tables containing a column using 'REFERENCES' and 'NOT NULL'.

To Reproduce

Good case:

CREATE TABLE a
(
    id UUID PRIMARY KEY
);

CREATE TABLE b
(
    id UUID PRIMARY KEY,
    a_id UUID REFERENCES a(id)
);

=> Will return two tables.

Bad case:

CREATE TABLE a
(
    id UUID PRIMARY KEY
);

CREATE TABLE b
(
    id UUID PRIMARY KEY,
    a_id UUID REFERENCES a(id) NOT NULL
);

=> Will only return a single table (a).

Expected behavior

All tables should be returned.

Environment:

xnuinside commented 4 months ago

fixed in version 1.0.4 https://github.com/xnuinside/simple-ddl-parser/pull/244

@Nerwerder, thanks for opening the issue!

xnuinside commented 4 months ago

version 1.0.4 was released, issue was fixed, if needed anything else - feel free to open a new issue