# "CHECK (((a > 1) AND (a < 5)))"
# "CHECK (((a = 1) OR ((a > 2) AND (a < 5))))"
def match_cons(src):
- m = re.match(r"^CHECK *\(\((.+)\)\)$", src)
+ m = re.match(r"^CHECK *\(\((.+)\)\)( NOT VALID)?$", src)
if not m:
util.warn("Could not parse CHECK constraint text: %r" % src)
return ""
):
testing.db.dialect.get_check_constraints(conn, "foo")
+ def test_reflect_with_not_valid_check_constraint(self):
+ conn = mock.Mock(
+ execute=lambda *arg, **kw: mock.Mock(
+ fetchall=lambda: [
+ ("some name", "CHECK ((a IS NOT NULL)) NOT VALID")
+ ]
+ )
+ )
+ with mock.patch.object(
+ testing.db.dialect, "get_table_oid", lambda *arg, **kw: 1
+ ):
+ check_constraints = testing.db.dialect.get_check_constraints(
+ conn, "foo"
+ )
+ eq_(
+ check_constraints,
+ [{u"name": u"some name", u"sqltext": u"a IS NOT NULL"}],
+ )
+
class CustomTypeReflectionTest(fixtures.TestBase):
class CustomType(object):