Skip to content

Commit 53c9649

Browse files
committed
SA20: Divert CrateCompiler.returning_clause to SA10/SA14 compilers
Apparently, `PGCompiler` does not have a specific implementation for `returning_clause`, starting with SA20. On the other hand, the generic implementation changed its method signature, that's why CodeQL would croak otherwise.
1 parent 3345b7a commit 53c9649

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

src/crate/client/sqlalchemy/compat/core10.py

+7
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
# software solely pursuant to the terms of the relevant commercial agreement.
2121

2222
import sqlalchemy as sa
23+
from sqlalchemy.dialects.postgresql.base import PGCompiler
2324
from sqlalchemy.sql.crud import (REQUIRED, _create_bind_param,
2425
_extend_values_for_multiparams,
2526
_get_multitable_params,
@@ -32,6 +33,12 @@
3233

3334
class CrateCompilerSA10(CrateCompiler):
3435

36+
def returning_clause(self, stmt, returning_cols):
37+
"""
38+
Generate RETURNING clause, PostgreSQL-compatible.
39+
"""
40+
return PGCompiler.returning_clause(self, stmt, returning_cols)
41+
3542
def visit_update(self, update_stmt, **kw):
3643
"""
3744
used to compile <sql.expression.Update> expressions

src/crate/client/sqlalchemy/compat/core14.py

+7
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
# software solely pursuant to the terms of the relevant commercial agreement.
2121

2222
import sqlalchemy as sa
23+
from sqlalchemy.dialects.postgresql.base import PGCompiler
2324
from sqlalchemy.sql import selectable
2425
from sqlalchemy.sql.crud import (REQUIRED, _create_bind_param,
2526
_extend_values_for_multiparams,
@@ -33,6 +34,12 @@
3334

3435
class CrateCompilerSA14(CrateCompiler):
3536

37+
def returning_clause(self, stmt, returning_cols):
38+
"""
39+
Generate RETURNING clause, PostgreSQL-compatible.
40+
"""
41+
return PGCompiler.returning_clause(self, stmt, returning_cols)
42+
3643
def visit_update(self, update_stmt, **kw):
3744

3845
compile_state = update_stmt._compile_state_factory(

src/crate/client/sqlalchemy/compiler.py

-6
Original file line numberDiff line numberDiff line change
@@ -221,12 +221,6 @@ def visit_any(self, element, **kw):
221221
self.process(element.right, **kw)
222222
)
223223

224-
def returning_clause(self, stmt, returning_cols):
225-
"""
226-
Generate RETURNING clause, PostgreSQL-compatible.
227-
"""
228-
return PGCompiler.returning_clause(self, stmt, returning_cols)
229-
230224
def limit_clause(self, select, **kw):
231225
"""
232226
Generate OFFSET / LIMIT clause, PostgreSQL-compatible.

0 commit comments

Comments
 (0)