diff options
author | mike bayer <mike_mp@zzzcomputing.com> | 2020-11-16 20:00:04 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@bbpush.zzzcomputing.com> | 2020-11-16 20:00:04 +0000 |
commit | 046248189c48722438c11988bfaea17433c0019f (patch) | |
tree | 0c6c6d28168628cd36f3d7b7f170ae11507165e8 /test/dialect/postgresql/test_compiler.py | |
parent | 218fc83f3997dc0c152278eea0740b088074784b (diff) | |
parent | 018aa9870110ef97316e9984c7ecd7f3357b501a (diff) | |
download | sqlalchemy-046248189c48722438c11988bfaea17433c0019f.tar.gz |
Merge "Add opsclass to exclusion constraint"
Diffstat (limited to 'test/dialect/postgresql/test_compiler.py')
-rw-r--r-- | test/dialect/postgresql/test_compiler.py | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/test/dialect/postgresql/test_compiler.py b/test/dialect/postgresql/test_compiler.py index dad7ccd3c..a031c3df9 100644 --- a/test/dialect/postgresql/test_compiler.py +++ b/test/dialect/postgresql/test_compiler.py @@ -820,13 +820,14 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): where="room > 100", deferrable=True, initially="immediate", + ops={"room": "my_opclass"}, ) tbl.append_constraint(cons) self.assert_compile( schema.AddConstraint(cons), "ALTER TABLE testtbl ADD CONSTRAINT my_name " "EXCLUDE USING gist " - "(room WITH =, during WITH " + "(room my_opclass WITH =, during WITH " "&&) WHERE " "(room > 100) DEFERRABLE INITIALLY immediate", dialect=postgresql.dialect(), @@ -935,6 +936,24 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): dialect=postgresql.dialect(), ) + def test_exclude_constraint_ops_many(self): + m = MetaData() + tbl = Table( + "testtbl", m, Column("room", String), Column("during", TSRANGE) + ) + cons = ExcludeConstraint( + ("room", "="), + ("during", "&&"), + ops={"room": "first_opsclass", "during": "second_opclass"}, + ) + tbl.append_constraint(cons) + self.assert_compile( + schema.AddConstraint(cons), + "ALTER TABLE testtbl ADD EXCLUDE USING gist " + "(room first_opsclass WITH =, during second_opclass WITH &&)", + dialect=postgresql.dialect(), + ) + def test_substring(self): self.assert_compile( func.substring("abc", 1, 2), |