Restrict column and index definitions to one line

This commit is contained in:
Peter J. Holzer 2022-05-05 11:27:24 +02:00
parent f71ce98af5
commit 2665e56e6f
2 changed files with 3 additions and 3 deletions

View File

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

View File

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