diff options
author | Federico Caselli <cfederico87@gmail.com> | 2023-02-22 21:57:19 +0100 |
---|---|---|
committer | Federico Caselli <cfederico87@gmail.com> | 2023-02-22 21:57:19 +0100 |
commit | 71693c94d52612a5e88128575ff308ee4a923c00 (patch) | |
tree | 40a75810ea3c857e3bd7bef056e5cf948f61f3a4 /test/dialect/postgresql/test_compiler.py | |
parent | fc57bafbae9d67b7ce95e26c939ca957c366b0f7 (diff) | |
download | sqlalchemy-71693c94d52612a5e88128575ff308ee4a923c00.tar.gz |
ExcludeConstraint literal_compile
ExcludeConstraint correctly uses literal compile
when compiling expression ddl.
Fixes: #9349
Change-Id: I11a994ac46556a972afc696a2baad7ddbdd3de97
Diffstat (limited to 'test/dialect/postgresql/test_compiler.py')
-rw-r--r-- | test/dialect/postgresql/test_compiler.py | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/test/dialect/postgresql/test_compiler.py b/test/dialect/postgresql/test_compiler.py index 080cfb767..e8bead008 100644 --- a/test/dialect/postgresql/test_compiler.py +++ b/test/dialect/postgresql/test_compiler.py @@ -1034,7 +1034,7 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): tbl.append_constraint(cons) self.assert_compile( schema.AddConstraint(cons), - "ALTER TABLE testtbl ADD EXCLUDE USING gist " "(room WITH =)", + "ALTER TABLE testtbl ADD EXCLUDE USING gist (room WITH =)", dialect=postgresql.dialect(), ) @@ -1134,7 +1134,7 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): tbl.append_constraint(cons_copy) self.assert_compile( schema.AddConstraint(cons_copy), - "ALTER TABLE testtbl ADD EXCLUDE USING gist " "(room WITH =)", + "ALTER TABLE testtbl ADD EXCLUDE USING gist (room WITH =)", ) def test_exclude_constraint_copy_where_using(self): @@ -1243,6 +1243,21 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): dialect=postgresql.dialect(), ) + def test_exclude_constraint_literal_binds(self): + m = MetaData() + tbl = Table("foo", m, Column("x", Integer), Column("y", Integer)) + cons = ExcludeConstraint( + (func.power(tbl.c.x, 42), "="), + (func.int8range(column("x"), "y"), "&&"), + ) + tbl.append_constraint(cons) + self.assert_compile( + schema.AddConstraint(cons), + "ALTER TABLE foo ADD EXCLUDE USING gist " + "(power(x, 42) WITH =, int8range(x, 'y') WITH &&)", + dialect=postgresql.dialect(), + ) + def test_substring(self): self.assert_compile( func.substring("abc", 1, 2), |