- Notifications
You must be signed in to change notification settings - Fork 46
Description
Description
When trying out simple-ddl-parser on some existing DDL, I attempted to parse 4 CREATE statements but I would only get 3 results. No exception was produced. By process of elimination, I found that this line was the source of the issue:
created_timestamp TIMESTAMPTZ NOT NULL DEFAULT (now() at time zone 'utc'),
However. with the following, the CREATE statement is parsed as expected:
created_timestamp TIMESTAMPTZ NOT NULL DEFAULT (now()),
Which suggests that the issue is around the "at time zone 'utc'" portion of the DFEAULT clause.
To Reproduce
Parse a CREATE statement including a TIMESTAMPTZ column with a DEFAULT clause including at time zone 'utc'. NOTE: the specific time zone used does not appear to matter.
Expected behavior
The CREATE statement should be parsed and included in parsing results. Although this statement is valid Postgres DDL, I would expect an exception when a statement is not parseable or at something other than just ignoring the CREATE statement. I did not see anything in the documentation about error handling, I apologize if I have overlooked that.
Example code
from simple_ddl_parser import DDLParser parser = DDLParser(""" CREATE TABLE example ( primary_key SERIAL PRIMARY KEY, created_timestamp TIMESTAMPTZ NOT NULL DEFAULT (now() at time zone 'utc') ); """) result = parser.run() print(len(result)) for r in result: print(r["table_name"]) Expected output: 1 followed by the table name: 'example'
Actual output: 0
Desktop (please complete the following information):
- OS: Windows10 (Gitbash/MINGW64)
- Version 0.24.2