From: Florian Apolloner Date: Wed, 17 Jan 2018 21:38:50 +0000 (-0500) Subject: Normalize check constraints even more radically X-Git-Tag: rel_1_2_2~5^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=afb121b0af8bd8a08f02031b5cf443b72dac952b;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Normalize check constraints even more radically 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 --- diff --git a/lib/sqlalchemy/testing/suite/test_reflection.py b/lib/sqlalchemy/testing/suite/test_reflection.py index f541165e33..0c391fad01 100644 --- a/lib/sqlalchemy/testing/suite/test_reflection.py +++ b/lib/sqlalchemy/testing/suite/test_reflection.py @@ -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_(