diff options
| author | mike bayer <mike_mp@zzzcomputing.com> | 2020-03-01 00:20:47 +0000 |
|---|---|---|
| committer | Gerrit Code Review <gerrit@bbpush.zzzcomputing.com> | 2020-03-01 00:20:47 +0000 |
| commit | b29f5ac39af8839760cd43d2184915d6f246e800 (patch) | |
| tree | 147f47135d04c1109361eaff544c4a2825ce51f3 /lib/sqlalchemy | |
| parent | e581f852fea04248ffbc736000b554b7c45c4585 (diff) | |
| parent | 0fe528483afeb53300ff7a9770f7fb9c81a3a874 (diff) | |
| download | sqlalchemy-b29f5ac39af8839760cd43d2184915d6f246e800.tar.gz | |
Merge "While parsing for check constraints, ignore newline characters in the check condition"
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/dialects/postgresql/base.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py index 0a442f256..bfe3812be 100644 --- a/lib/sqlalchemy/dialects/postgresql/base.py +++ b/lib/sqlalchemy/dialects/postgresql/base.py @@ -3488,12 +3488,18 @@ class PGDialect(default.DefaultDialect): # "CHECK (((a = 1) OR ((a > 2) AND (a < 5))))" # "CHECK (((a > 1) AND (a < 5))) NOT VALID" # "CHECK (some_boolean_function(a))" - m = re.match(r"^CHECK *\((.+)\)( NOT VALID)?$", src) + # "CHECK (((a\n < 1)\n OR\n (a\n >= 5))\n)" + + m = re.match( + r"^CHECK *\((.+)\)( NOT VALID)?$", src, flags=re.DOTALL + ) if not m: util.warn("Could not parse CHECK constraint text: %r" % src) sqltext = "" else: - sqltext = re.sub(r"^\((.+)\)$", r"\1", m.group(1)) + sqltext = re.compile( + r"^[\s\n]*\((.+)\)[\s\n]*$", flags=re.DOTALL + ).sub(r"\1", m.group(1)) entry = {"name": name, "sqltext": sqltext} if m and m.group(2): entry["dialect_options"] = {"not_valid": True} |
