From 33b680c49b781c8ddda18507696e32c3c0e0ccf1 Mon Sep 17 00:00:00 2001 From: "Peter J. Holzer" Date: Tue, 19 Apr 2022 14:59:56 +0200 Subject: [PATCH] Accept some additional SQL types Still far from complete ... --- setup.cfg | 2 +- src/procrusql/parser.py | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/setup.cfg b/setup.cfg index e8eda2f..7d55f46 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = ProcruSQL -version = 0.0.3 +version = 0.0.4 author = Peter J. Holzer author_email = hjp@hjp.at description = Make a database fit its description diff --git a/src/procrusql/parser.py b/src/procrusql/parser.py index 5d33596..c087a56 100755 --- a/src/procrusql/parser.py +++ b/src/procrusql/parser.py @@ -212,7 +212,14 @@ def parse_column_definition(ps): ps2 = ps.clone() ps2.ast = [] ps2.skip_whitespace_and_comments() - m = ps2.match(r"(int|serial|text|boolean)(\s+not null)?(\s+(primary key|unique|references \w+))?\b") + sqltypes = ( + "int", "integer", "serial", + "boolean", + "text", "character varying", + "date", "timestamp with time zone", "timestamptz" + ) + pattern = "(" + "|".join(sqltypes) + ")" + r"(\s+default .*)?(\s+not null)?(\s+(primary key|unique|references \w+))?\b" + m = ps2.match(pattern) if not m: ps.record_child_failure(ps2, "expected column definition") return