# "CHECK (some_boolean_function(a))"
# "CHECK (((a\n < 1)\n OR\n (a\n >= 5))\n)"
# "CHECK (a NOT NULL) NO INHERIT"
+ # "CHECK (a NOT NULL) NO INHERIT NOT VALID"
m = re.match(
- r"^CHECK *\((.+)\)( NOT VALID)?( NO INHERIT)?$", src, flags=re.DOTALL
+ r"^CHECK *\((.+)\)( NO INHERIT)?( NOT VALID)?$", src, flags=re.DOTALL
)
if not m:
util.warn("Could not parse CHECK constraint text: %r" % src)
"sqltext": sqltext,
"comment": comment,
}
- if m and m.group(2):
+ if m and " NOT VALID" in m.groups():
entry["dialect_options"] = {"not_valid": True}
check_constraints[(schema, table_name)].append(entry)
def test_reflect_with_no_inherit_check_constraint(self):
rows = [
- ("foo", "some name", "CHECK ((a IS NOT NULL)) NO INHERIT", None)
+ ("foo", "some name", "CHECK ((a IS NOT NULL)) NO INHERIT", None),
+ ("foo", "some name", "CHECK ((a IS NOT NULL)) NO INHERIT NOT VALID", None),
]
conn = mock.Mock(
execute=lambda *arg, **kw: mock.MagicMock(
{
"name": "some name",
"sqltext": "a IS NOT NULL",
- "dialect_options": {"no_inherit": True},
"comment": None,
- }
+ },
+ {
+ "name": "some name",
+ "sqltext": "a IS NOT NULL",
+ "dialect_options": {"not_valid": True},
+ "comment": None,
+ },
],
)