]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Normalize check constraints even more radically
authorFlorian Apolloner <apollo13@users.noreply.github.com>
Wed, 17 Jan 2018 21:38:50 +0000 (16:38 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 17 Jan 2018 21:38:50 +0000 (16:38 -0500)
This is the only way I could get this test pass on informix, basically I strip every whitespace.
The sql text as recorded in informix is:
```
((a > 1 ) AND (a < 5 ) )
((a = 1 ) OR ((a > 2 ) AND (a <5 ) ) )
```
Yes, this is absolutely bonkers, but that is what I get :(

Change-Id: I936e860f2b75b521e5560c05c452dbe72f0d3812
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/413

lib/sqlalchemy/testing/suite/test_reflection.py

index f541165e3334684e72fe01a42a914d25c6fe3c1d..0c391fad01e3fea459bd6bb0c74434005d061539 100644 (file)
@@ -789,12 +789,15 @@ class ComponentReflectionTest(fixtures.TablesTest):
             key=operator.itemgetter('name')
         )
 
+        # trying to minimize effect of quoting, parenthesis, etc.
+        # may need to add more to this as new dialects get CHECK
+        # constraint reflection support
+        def normalize(sqltext):
+            return " ".join(re.findall(r"and|\d|=|a|or|<|>", sqltext.lower(), re.I))
+
         reflected = [
             {"name": item["name"],
-             # trying to minimize effect of quoting, parenthesis, etc.
-             # may need to add more to this as new dialects get CHECK
-             # constraint reflection support
-             "sqltext": re.sub(r"[`'\(\)]", '', item["sqltext"].lower())}
+             "sqltext": normalize(item["sqltext"])}
             for item in reflected
         ]
         eq_(