diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-09-07 17:13:23 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-09-07 19:10:53 -0400 |
| commit | 885c61cf226695cafa12e56ed047ba761c2f7f93 (patch) | |
| tree | 661d781abe8ab09433c39a5c4bdd1e6d00d8a6bb /lib/sqlalchemy/dialects/sqlite | |
| parent | 06fe424256a80b91e9ff87b3bbe12ea93bc59453 (diff) | |
| download | sqlalchemy-885c61cf226695cafa12e56ed047ba761c2f7f93.tar.gz | |
enable UPDATE..FROM for SQLite
The SQLite dialect now supports UPDATE..FROM syntax, for UPDATE statements
that may refer to additional tables within the WHERE criteria of the
statement without the need to use subqueries. This syntax is invoked
automatically when using the :class:`_dml.Update` construct when more than
one table or other entity or selectable is used.
Fixes: #7185
Change-Id: I27e94ace9ff761cc45e652fa1abff8cd1f42fec5
Diffstat (limited to 'lib/sqlalchemy/dialects/sqlite')
| -rw-r--r-- | lib/sqlalchemy/dialects/sqlite/base.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/sqlalchemy/dialects/sqlite/base.py b/lib/sqlalchemy/dialects/sqlite/base.py index 222f3a137..88c6dbe18 100644 --- a/lib/sqlalchemy/dialects/sqlite/base.py +++ b/lib/sqlalchemy/dialects/sqlite/base.py @@ -1381,6 +1381,15 @@ class SQLiteCompiler(compiler.SQLCompiler): # sqlite has no "FOR UPDATE" AFAICT return "" + def update_from_clause( + self, update_stmt, from_table, extra_froms, from_hints, **kw + ): + kw["asfrom"] = True + return "FROM " + ", ".join( + t._compiler_dispatch(self, fromhints=from_hints, **kw) + for t in extra_froms + ) + def visit_is_distinct_from_binary(self, binary, operator, **kw): return "%s IS NOT %s" % ( self.process(binary.left), @@ -1933,6 +1942,7 @@ class SQLiteDialect(default.DefaultDialect): insert_returning = True update_returning = True delete_returning = True + update_returning_multifrom = True default_paramstyle = "qmark" execution_ctx_cls = SQLiteExecutionContext |
