diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2017-01-30 12:10:16 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2017-01-30 12:10:16 -0500 |
commit | 1c578a710f14568856dad6a1c0bad1269b4108c4 (patch) | |
tree | 452686e86ae0937fc0e9fa31e0b0614521871a32 /test/dialect/postgresql/test_compiler.py | |
parent | f55d466cad2d7c741f391eb2df15a23652132fe4 (diff) | |
download | sqlalchemy-1c578a710f14568856dad6a1c0bad1269b4108c4.tar.gz |
Copy whereclause / using in ExcludeConstraint
Fixed bug in Postgresql :class:`.ExcludeConstraint` where the
"whereclause" and "using" parameters would not be copied during an
operation like :meth:`.Table.tometadata`.
Change-Id: I2f704981d4d4862f9c82a50272006fab8becebb6
Fixes: #3900
Diffstat (limited to 'test/dialect/postgresql/test_compiler.py')
-rw-r--r-- | test/dialect/postgresql/test_compiler.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/dialect/postgresql/test_compiler.py b/test/dialect/postgresql/test_compiler.py index 99706bad8..160641855 100644 --- a/test/dialect/postgresql/test_compiler.py +++ b/test/dialect/postgresql/test_compiler.py @@ -555,6 +555,30 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): 'ALTER TABLE testtbl ADD EXCLUDE USING gist ' '(room WITH =)') + def test_exclude_constraint_copy_where_using(self): + m = MetaData() + tbl = Table('testtbl', m, + Column('room', Integer, primary_key=True), + ) + cons = ExcludeConstraint( + (tbl.c.room, '='), where=tbl.c.room > 5, using='foobar') + tbl.append_constraint(cons) + self.assert_compile( + schema.AddConstraint(cons), + "ALTER TABLE testtbl ADD EXCLUDE USING foobar " + "(room WITH =) WHERE (testtbl.room > 5)" + ) + + m2 = MetaData() + tbl2 = tbl.tometadata(m2) + self.assert_compile( + schema.CreateTable(tbl2), + "CREATE TABLE testtbl (room SERIAL NOT NULL, " + "PRIMARY KEY (room), " + "EXCLUDE USING foobar " + "(room WITH =) WHERE (testtbl.room > 5))" + ) + def test_exclude_constraint_text(self): m = MetaData() cons = ExcludeConstraint((text('room::TEXT'), '=')) |