Skip to content

Commit ca19003

Browse files
committed
Add support for RETURNING in SQLAlchemy dialect
1 parent 1f3189e commit ca19003

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/crate/client/sqlalchemy/compiler.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,13 @@ def visit_any(self, element, **kw):
177177
self.process(element.right, **kw)
178178
)
179179

180+
def returning_clause(self, stmt, returning_cols):
181+
columns = [
182+
self._label_select_column(None, c, True, False, {})
183+
for c in sa.sql.expression._select_iterables(returning_cols)
184+
]
185+
return "RETURNING " + ", ".join(columns)
186+
180187
def visit_insert(self, insert_stmt, asfrom=False, **kw):
181188
"""
182189
used to compile <sql.expression.Insert> expressions.

src/crate/client/sqlalchemy/dialect.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ class CrateDialect(default.DefaultDialect):
165165
type_compiler = CrateTypeCompiler
166166
supports_native_boolean = True
167167
colspecs = colspecs
168+
implicit_returning = True
168169

169170
def __init__(self, *args, **kwargs):
170171
super(CrateDialect, self).__init__(*args, **kwargs)

0 commit comments

Comments
 (0)