summaryrefslogtreecommitdiff
path: root/test/sql/test_operators.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2021-04-02 11:06:28 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2021-04-02 11:08:10 -0400
commita16687b3fc4179e8f42d8099aa6d1e6d18fedf70 (patch)
tree562b2f5b7875abd28cbcc014cadbfa810b3a7bb5 /test/sql/test_operators.py
parentba3e6860930b88f6c704250ccc711eb6965d0da0 (diff)
downloadsqlalchemy-a16687b3fc4179e8f42d8099aa6d1e6d18fedf70.tar.gz
Ensure Grouping._with_binary_element_type() maintains class
Fixed regression where use of the :meth:`.Operators.in_` method with a :class:`_sql.Select` object against a non-table-bound column would produce an ``AttributeError``, or more generally using a :class:`_sql.ScalarSelect` that has no datatype in a binary expression would produce invalid state. Fixes: #6181 Change-Id: I1ddea433b3603fdab8f489bff571b512a6ffc66b
Diffstat (limited to 'test/sql/test_operators.py')
-rw-r--r--test/sql/test_operators.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/sql/test_operators.py b/test/sql/test_operators.py
index f6a13f8ca..0d7f331e0 100644
--- a/test/sql/test_operators.py
+++ b/test/sql/test_operators.py
@@ -1973,6 +1973,22 @@ class InTest(fixtures.TestBase, testing.AssertsCompiledSQL):
checkparams={"myid_1": [1, 2, 3]},
)
+ def test_scalar_subquery_wo_type(self):
+ """ test for :ticket:`6181` """
+
+ m = MetaData()
+ t = Table("t", m, Column("a", Integer))
+
+ # the scalar subquery of this will have no type; coercions will
+ # want to call _with_binary_element_type(); that has to return
+ # a scalar select
+ req = select(column("scan"))
+
+ self.assert_compile(
+ select(t.c.a).where(t.c.a.in_(req)),
+ "SELECT t.a FROM t WHERE t.a IN (SELECT scan)",
+ )
+
class MathOperatorTest(fixtures.TestBase, testing.AssertsCompiledSQL):
__dialect__ = "default"