diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2018-10-03 10:40:38 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2018-10-03 10:40:38 -0400 |
commit | aa2128427064a2bdeaeff5dc946ecbb3727c90aa (patch) | |
tree | 62e207bb41e8569727153c144f4d650d4981d02c /lib/sqlalchemy/dialects/postgresql/base.py | |
parent | ffd27cef48241e39725c4e9cd13fd744a2806bdd (diff) | |
download | sqlalchemy-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/postgresql/base.py')
-rw-r--r-- | lib/sqlalchemy/dialects/postgresql/base.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py index 11fcc41d5..5251a000d 100644 --- a/lib/sqlalchemy/dialects/postgresql/base.py +++ b/lib/sqlalchemy/dialects/postgresql/base.py @@ -1485,14 +1485,17 @@ class PGCompiler(compiler.SQLCompiler): if escape else '' ) - def visit_empty_set_expr(self, type_, **kw): + def visit_empty_set_expr(self, element_types): # cast the empty set to the type we are comparing against. if # we are comparing against the null type, pick an arbitrary # datatype for the empty set - if type_._isnull: - type_ = INTEGER() - return 'SELECT CAST(NULL AS %s) WHERE 1!=1' % \ - self.dialect.type_compiler.process(type_, **kw) + return 'SELECT %s WHERE 1!=1' % ( + ", ".join( + "CAST(NULL AS %s)" % self.dialect.type_compiler.process( + INTEGER() if type_._isnull else type_, + ) for type_ in element_types or [INTEGER()] + ), + ) def render_literal_value(self, value, type_): value = super(PGCompiler, self).render_literal_value(value, type_) |