summaryrefslogtreecommitdiff
path: root/test/dialect/postgresql
diff options
context:
space:
mode:
Diffstat (limited to 'test/dialect/postgresql')
-rw-r--r--test/dialect/postgresql/test_compiler.py32
-rw-r--r--test/dialect/postgresql/test_types.py33
2 files changed, 44 insertions, 21 deletions
diff --git a/test/dialect/postgresql/test_compiler.py b/test/dialect/postgresql/test_compiler.py
index 2221fd30a..0fe5f7066 100644
--- a/test/dialect/postgresql/test_compiler.py
+++ b/test/dialect/postgresql/test_compiler.py
@@ -1506,48 +1506,48 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
)
self.assert_compile(
postgresql.Any(4, c),
- "%(param_1)s = ANY (x)",
- checkparams={"param_1": 4},
+ "%(x_1)s = ANY (x)",
+ checkparams={"x_1": 4},
)
self.assert_compile(
c.any(5),
- "%(param_1)s = ANY (x)",
- checkparams={"param_1": 5},
+ "%(x_1)s = ANY (x)",
+ checkparams={"x_1": 5},
)
self.assert_compile(
~c.any(5),
- "NOT (%(param_1)s = ANY (x))",
- checkparams={"param_1": 5},
+ "NOT (%(x_1)s = ANY (x))",
+ checkparams={"x_1": 5},
)
self.assert_compile(
c.all(5),
- "%(param_1)s = ALL (x)",
- checkparams={"param_1": 5},
+ "%(x_1)s = ALL (x)",
+ checkparams={"x_1": 5},
)
self.assert_compile(
~c.all(5),
- "NOT (%(param_1)s = ALL (x))",
- checkparams={"param_1": 5},
+ "NOT (%(x_1)s = ALL (x))",
+ checkparams={"x_1": 5},
)
self.assert_compile(
c.any(5, operator=operators.ne),
- "%(param_1)s != ANY (x)",
- checkparams={"param_1": 5},
+ "%(x_1)s != ANY (x)",
+ checkparams={"x_1": 5},
)
self.assert_compile(
postgresql.All(6, c, operator=operators.gt),
- "%(param_1)s > ALL (x)",
- checkparams={"param_1": 6},
+ "%(x_1)s > ALL (x)",
+ checkparams={"x_1": 6},
)
self.assert_compile(
c.all(7, operator=operators.lt),
- "%(param_1)s < ALL (x)",
- checkparams={"param_1": 7},
+ "%(x_1)s < ALL (x)",
+ checkparams={"x_1": 7},
)
@testing.combinations(
diff --git a/test/dialect/postgresql/test_types.py b/test/dialect/postgresql/test_types.py
index 8c4bb7fe7..bca952ade 100644
--- a/test/dialect/postgresql/test_types.py
+++ b/test/dialect/postgresql/test_types.py
@@ -1271,16 +1271,16 @@ class ArrayTest(AssertsCompiledSQL, fixtures.TestBase):
col = column("x", postgresql.ARRAY(Integer))
self.assert_compile(
select(col.any(7, operator=operators.lt)),
- "SELECT %(param_1)s < ANY (x) AS anon_1",
- checkparams={"param_1": 7},
+ "SELECT %(x_1)s < ANY (x) AS anon_1",
+ checkparams={"x_1": 7},
)
def test_array_all(self):
col = column("x", postgresql.ARRAY(Integer))
self.assert_compile(
select(col.all(7, operator=operators.lt)),
- "SELECT %(param_1)s < ALL (x) AS anon_1",
- checkparams={"param_1": 7},
+ "SELECT %(x_1)s < ALL (x) AS anon_1",
+ checkparams={"x_1": 7},
)
def test_array_contains(self):
@@ -2404,7 +2404,10 @@ class ArrayEnum(fixtures.TestBase):
metadata.create_all(connection)
connection.execute(
tbl.insert(),
- [{"enum_col": ["foo"]}, {"enum_col": ["foo", "bar"]}],
+ [
+ {"enum_col": ["foo"], "pyenum_col": [MyEnum.a, MyEnum.b]},
+ {"enum_col": ["foo", "bar"], "pyenum_col": [MyEnum.b]},
+ ],
)
return tbl, MyEnum
@@ -2423,6 +2426,26 @@ class ArrayEnum(fixtures.TestBase):
)
@_enum_combinations
+ @testing.combinations("all", "any", argnames="fn")
+ def test_any_all_roundtrip(
+ self, array_of_enum_fixture, connection, array_cls, enum_cls, fn
+ ):
+ """test #6515"""
+
+ tbl, MyEnum = array_of_enum_fixture(array_cls, enum_cls)
+
+ if fn == "all":
+ expr = tbl.c.pyenum_col.all(MyEnum.b)
+ result = [([MyEnum.b],)]
+ elif fn == "any":
+ expr = tbl.c.pyenum_col.any(MyEnum.b)
+ result = [([MyEnum.a, MyEnum.b],), ([MyEnum.b],)]
+ else:
+ assert False
+ sel = select(tbl.c.pyenum_col).where(expr).order_by(tbl.c.id)
+ eq_(connection.execute(sel).fetchall(), result)
+
+ @_enum_combinations
def test_array_of_enums_roundtrip(
self, array_of_enum_fixture, connection, array_cls, enum_cls
):