From 2da6559fc2734a994e678785750c2e733c32d380 Mon Sep 17 00:00:00 2001 From: "Peter J. Holzer" Date: Thu, 8 Sep 2022 12:06:14 +0200 Subject: [PATCH] Allow column constraints in any order --- setup.cfg | 2 +- src/procrusql/parser.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.cfg b/setup.cfg index e776854..2e9c94d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = ProcruSQL -version = 0.0.7 +version = 0.0.8 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 87a59f2..3cb00d8 100755 --- a/src/procrusql/parser.py +++ b/src/procrusql/parser.py @@ -291,7 +291,7 @@ def parse_column_definition(ps): "text", "character varying", "date", "timestamp with time zone", "timestamptz" ) - pattern = "(" + "|".join(sqltypes) + ")" + r"([ \t]+default .*)?([ \t]+not null)?([ \t]+(primary key|unique|references \w+))?\b" + pattern = "(" + "|".join(sqltypes) + ")" + r"([ \t]+(default .*|not null\b|primary key\b|unique\b|references \w+\b))*" m = ps2.match(pattern) if not m: ps.record_child_failure(ps2, "expected column definition")