Compare commits

..

6 Commits

Author SHA1 Message Date
Peter J. Holzer 05e43907a5 Set version to 0.16 2025-03-14 12:44:31 +01:00
Peter J. Holzer 12dcf05eaf Merge branch 'master' of git.hjp.at:hjp/procrusql 2024-12-12 21:51:30 +01:00
Peter J. Holzer 43272bb96a Add schema support for data rules 2024-12-12 21:51:05 +01:00
Peter J. Holzer d31204cd5c Add view definitions 2024-12-12 21:50:25 +01:00
Peter J. Holzer 8f93c2e2da Add type bytea 2024-12-12 21:48:31 +01:00
Peter J. Holzer 363cdcede1 Make error messages more readable 2024-12-12 21:48:06 +01:00
2 changed files with 20 additions and 3 deletions

View File

@ -1,6 +1,6 @@
[metadata] [metadata]
name = ProcruSQL name = ProcruSQL
version = 0.0.15 version = 0.0.16
author = Peter J. Holzer author = Peter J. Holzer
author_email = hjp@hjp.at author_email = hjp@hjp.at
description = Make a database fit its description description = Make a database fit its description
@ -9,6 +9,7 @@ long_description_content_type = text/markdown
url = https://git.hjp.at:3000/hjp/procrusql url = https://git.hjp.at:3000/hjp/procrusql
project_urls = project_urls =
Bug Tracker = https://git.hjp.at:3000/hjp/procrusql/issues Bug Tracker = https://git.hjp.at:3000/hjp/procrusql/issues
Repository = https://git.hjp.at:3000/hjp/procrusql
classifiers = classifiers =
Programming Language :: Python :: 3 Programming Language :: Python :: 3
License :: OSI Approved :: MIT License License :: OSI Approved :: MIT License

View File

@ -43,7 +43,7 @@ class ParseState:
linesbefore = self.text[:position].split("\n") linesbefore = self.text[:position].split("\n")
linesafter = self.text[position:].split("\n") linesafter = self.text[position:].split("\n")
good = "\x1B[40;32m" good = "\x1B[40;32m"
bad = "\x1B[40;31m" bad = "\x1B[40;31;1m"
reset = "\x1B[0m" reset = "\x1B[0m"
s = reset + message + "\n" s = reset + message + "\n"
lines = [] lines = []
@ -79,7 +79,8 @@ def parse_ruleset(ps):
ps3 = parse_table_rule(ps2) or \ ps3 = parse_table_rule(ps2) or \
parse_column_rule(ps2) or \ parse_column_rule(ps2) or \
parse_data_rule(ps2) or \ parse_data_rule(ps2) or \
parse_index_rule(ps2) parse_index_rule(ps2) or \
parse_view_rule(ps2)
if ps3: if ps3:
ps2.ast.append(ps3.ast) ps2.ast.append(ps3.ast)
ps2.position = ps3.position ps2.position = ps3.position
@ -273,6 +274,20 @@ def parse_index_rule(ps):
return ps2 return ps2
def parse_view_rule(ps):
ps2 = ps.clone()
ps2.skip_whitespace_and_comments()
if not ps2.match(r"view\b"):
ps.record_child_failure(ps2, "expected “view”")
return
ps2.skip_whitespace_and_comments()
ps3 = parse_table_name(ps2)
if not ps3:
ps.record_child_failure(ps2, "expected view name")
return
ps2.skip_whitespace_and_comments()
ps3 = parse_multiline_string(ps2)
def parse_table_name(ps): def parse_table_name(ps):
@ -340,6 +355,7 @@ def parse_column_definition(ps):
"json", "jsonb", "json", "jsonb",
"uuid", "uuid",
r"integer\[\]", r"int\[\]", r"bigint\[\]", r"integer\[\]", r"int\[\]", r"bigint\[\]",
"bytea",
), ),
key=lambda x: -len(x) # longest match first key=lambda x: -len(x) # longest match first
) )