summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects/mysql/base.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2018-10-03 10:40:38 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2018-10-03 10:40:38 -0400
commitaa2128427064a2bdeaeff5dc946ecbb3727c90aa (patch)
tree62e207bb41e8569727153c144f4d650d4981d02c /lib/sqlalchemy/dialects/mysql/base.py
parentffd27cef48241e39725c4e9cd13fd744a2806bdd (diff)
downloadsqlalchemy-aa2128427064a2bdeaeff5dc946ecbb3727c90aa.tar.gz
Support tuples of heterogeneous types for empty expanding IN
Pass a list of all the types for the left side of an IN expression to the visit_empty_set_expr() method, so that the "empty expanding IN" can produce clauses for each element. Fixes: #4271 Change-Id: I2738b9df2292ac01afda37f16d4fa56ae7bf9147
Diffstat (limited to 'lib/sqlalchemy/dialects/mysql/base.py')
-rw-r--r--lib/sqlalchemy/dialects/mysql/base.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/sqlalchemy/dialects/mysql/base.py b/lib/sqlalchemy/dialects/mysql/base.py
index 45e8c2510..43966d1dc 100644
--- a/lib/sqlalchemy/dialects/mysql/base.py
+++ b/lib/sqlalchemy/dialects/mysql/base.py
@@ -1179,8 +1179,18 @@ class MySQLCompiler(compiler.SQLCompiler):
fromhints=from_hints, **kw)
for t in [from_table] + extra_froms)
- def visit_empty_set_expr(self, type_):
- return 'SELECT 1 FROM (SELECT 1) as _empty_set WHERE 1!=1'
+ def visit_empty_set_expr(self, element_types):
+ return (
+ "SELECT %(outer)s FROM (SELECT %(inner)s) "
+ "as _empty_set WHERE 1!=1" % {
+ "inner": ", ".join(
+ "1 AS _in_%s" % idx
+ for idx, type_ in enumerate(element_types)),
+ "outer": ", ".join(
+ "_in_%s" % idx
+ for idx, type_ in enumerate(element_types))
+ }
+ )
class MySQLDDLCompiler(compiler.DDLCompiler):