|
3 | 3 | import six
|
4 | 4 | from sqlalchemy import schema, types as sqltypes, exc, util as sa_util
|
5 | 5 | from sqlalchemy.engine import default, reflection
|
6 |
| -from sqlalchemy.sql import compiler, expression, type_api |
| 6 | +from sqlalchemy.sql import compiler, expression, type_api, crud |
7 | 7 | from sqlalchemy.types import DATE, DATETIME, INTEGER, VARCHAR, FLOAT
|
8 | 8 |
|
9 | 9 | from .. import types
|
@@ -179,6 +179,26 @@ def visit_join(self, join, asfrom=False, **kwargs):
|
179 | 179 | "ON", self.process(join.onclause, asfrom=True, **kwargs)
|
180 | 180 | ))
|
181 | 181 |
|
| 182 | + def visit_update(self, update_stmt, asfrom=False, **kw): |
| 183 | + text = 'ALTER TABLE ' |
| 184 | + table_text = self.update_tables_clause(update_stmt, update_stmt.table, [], **kw) |
| 185 | + text += table_text |
| 186 | + text += ' UPDATE ' |
| 187 | + crud_params = crud._setup_crud_params( |
| 188 | + self, update_stmt, crud.ISUPDATE, include_table=False, **kw) |
| 189 | + |
| 190 | + text += ', '.join( |
| 191 | + c[0]._compiler_dispatch(self, |
| 192 | + include_table=False) + |
| 193 | + '=' + c[1] for c in crud_params |
| 194 | + ) |
| 195 | + |
| 196 | + if update_stmt._whereclause is not None: |
| 197 | + t = update_stmt._whereclause._compiler_dispatch(self, include_table=False) |
| 198 | + if t: |
| 199 | + text += " WHERE " + t |
| 200 | + return text |
| 201 | + |
182 | 202 |
|
183 | 203 | class ClickHouseDDLCompiler(compiler.DDLCompiler):
|
184 | 204 | def visit_create_column(self, create, **kw):
|
|
0 commit comments