diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2019-07-16 12:41:09 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2019-07-19 13:08:06 -0400 |
| commit | 88168db8e9a51ce438e06bfe792e758ed9297ab8 (patch) | |
| tree | e9ce458fdcc4f43c288e1c823476af21bb350d9a /lib/sqlalchemy/dialects/sqlite | |
| parent | c01f90de584f50f036c5b6d0c44074b4b3014da4 (diff) | |
| download | sqlalchemy-88168db8e9a51ce438e06bfe792e758ed9297ab8.tar.gz | |
Support tuple IN VALUES for SQLite, others
Added support for composite (tuple) IN operators with SQLite, by rendering
the VALUES keyword for this backend. As other backends such as DB2 are
known to use the same syntax, the syntax is enabled in the base compiler
using a dialect-level flag ``tuple_in_values``. The change also includes
support for "empty IN tuple" expressions for SQLite when using "in_()"
between a tuple value and an empty set.
Fixes: #4766
Change-Id: I416e1af29b31d78f9ae06ec3c3a48ef6d6e813f5
Diffstat (limited to 'lib/sqlalchemy/dialects/sqlite')
| -rw-r--r-- | lib/sqlalchemy/dialects/sqlite/base.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/sqlalchemy/dialects/sqlite/base.py b/lib/sqlalchemy/dialects/sqlite/base.py index b6ca8fe3c..c9309cbad 100644 --- a/lib/sqlalchemy/dialects/sqlite/base.py +++ b/lib/sqlalchemy/dialects/sqlite/base.py @@ -1023,8 +1023,11 @@ class SQLiteCompiler(compiler.SQLCompiler): self.process(binary.right, **kw), ) - def visit_empty_set_expr(self, type_): - return "SELECT 1 FROM (SELECT 1) WHERE 1!=1" + def visit_empty_set_expr(self, element_types): + return "SELECT %s FROM (SELECT %s) WHERE 1!=1" % ( + ", ".join("1" for type_ in element_types or [INTEGER()]), + ", ".join("1" for type_ in element_types or [INTEGER()]), + ) class SQLiteDDLCompiler(compiler.DDLCompiler): @@ -1391,6 +1394,7 @@ class SQLiteDialect(default.DefaultDialect): supports_empty_insert = False supports_cast = True supports_multivalues_insert = True + tuple_in_values = True default_paramstyle = "qmark" execution_ctx_cls = SQLiteExecutionContext |
