From 2665e56e6ff62f9673fc32352a7101d194f0e8b5 Mon Sep 17 00:00:00 2001 From: "Peter J. Holzer" Date: Thu, 5 May 2022 11:27:24 +0200 Subject: [PATCH] Restrict column and index definitions to one line --- setup.cfg | 2 +- src/procrusql/parser.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/setup.cfg b/setup.cfg index d0c6439..a622587 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = ProcruSQL -version = 0.0.5 +version = 0.0.6 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 7ade364..5decaff 100755 --- a/src/procrusql/parser.py +++ b/src/procrusql/parser.py @@ -209,7 +209,7 @@ def parse_index_rule(ps): table_name = ps3.ast[0] ps2.position = ps3.position - m = ps2.match(r"\s*(using\b|\([\w, ]+\))[^>]*") + m = ps2.match(r"\s*(using\b|\([\w, ]+\))[^>\n]*") if not m: ps.record_child_failure(ps2, "expected “using” or column list") index_definition = m.group(0) @@ -282,7 +282,7 @@ def parse_column_definition(ps): "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" + pattern = "(" + "|".join(sqltypes) + ")" + r"([ \t]+default .*)?([ \t]+not null)?([ \t]+(primary key|unique|references \w+))?\b" m = ps2.match(pattern) if not m: ps.record_child_failure(ps2, "expected column definition")