summaryrefslogtreecommitdiff
path: root/test/dialect/postgresql/test_compiler.py
diff options
context:
space:
mode:
authorAlonM <alon.menczer@gmail.com>2020-11-15 08:13:25 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2020-11-16 14:02:49 -0500
commit018aa9870110ef97316e9984c7ecd7f3357b501a (patch)
tree2269fd252e87c83c4ad31925a7840124564871e1 /test/dialect/postgresql/test_compiler.py
parentbddb1070f9fa846233255fd0acd5316404560de1 (diff)
downloadsqlalchemy-018aa9870110ef97316e9984c7ecd7f3357b501a.tar.gz
Add opsclass to exclusion constraint
Added new parameter :paramref:`_postgresql.ExcludeConstraint.ops` to the :class:`_postgresql.ExcludeConstraint` object, to support operator class specification with this constraint. Pull request courtesy Alon Menczer. Fixes: #5604 Closes: #5700 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5700 Pull-request-sha: f8613e100792fc0bb3cf300ec6aebc78ecdf0361 Change-Id: Iaf664131ec84f8c2fb05edf799198b8d3bb83597
Diffstat (limited to 'test/dialect/postgresql/test_compiler.py')
-rw-r--r--test/dialect/postgresql/test_compiler.py21
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),