Accept some additional SQL types

Still far from complete ...
This commit is contained in:
Peter J. Holzer 2022-04-19 14:59:56 +02:00 committed by Peter J. Holzer
parent 15e558c90b
commit 33b680c49b
2 changed files with 9 additions and 2 deletions

View File

@ -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

View File

@ -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