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

GENERATED BY DEFAULT and CONSTRAINT with CHECK #268

Open erwin-frohsinn opened 3 weeks ago

erwin-frohsinn commented 3 weeks ago

Describe the bug The following is not parsed:

CREATE TABLE pole.t_zuschauer (
    id int4 GENERATED BY DEFAULT AS IDENTITY( INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START 1 CACHE 1 NO CYCLE) NOT NULL, -- Zuschauer-Nr.(Primärschlüssel)
    email varchar(50) NULL, -- email-Adresse
    CONSTRAINT t_zuschauer_email CHECK (((email IS NULL) OR ((email)::text = ''::text) OR ((email)::text ~* '([a-zA-Z0-9._%+-]+)@([a-zA-Z0-9.-]+)\.[a-zA-Z]{2,}'::text))),
    CONSTRAINT t_zuschauer_id PRIMARY KEY (id)
);

To Reproduce Parse with simple_ddl_parser

Desktop (please complete the following information):

Probable causes: id contains valid ddl code but prevents the columns from being parsed the constraint which checks the the email is not accepted