Skip to content

Commit

Permalink
SA20: Divert CrateCompiler.returning_clause to SA10/SA14 compilers
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
amotl committed Jan 27, 2023
1 parent ee6144d commit dfcdd0f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
7 changes: 7 additions & 0 deletions src/crate/client/sqlalchemy/compat/core10.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# software solely pursuant to the terms of the relevant commercial agreement.

import sqlalchemy as sa
from sqlalchemy.dialects.postgresql.base import PGCompiler
from sqlalchemy.sql.crud import (REQUIRED, _create_bind_param,
_extend_values_for_multiparams,
_get_multitable_params,
Expand All @@ -32,6 +33,12 @@

class CrateCompilerSA10(CrateCompiler):

def returning_clause(self, stmt, returning_cols):
"""
Generate RETURNING clause, PostgreSQL-compatible.
"""
return PGCompiler.returning_clause(self, stmt, returning_cols)

def visit_update(self, update_stmt, **kw):
"""
used to compile <sql.expression.Update> expressions
Expand Down
7 changes: 7 additions & 0 deletions src/crate/client/sqlalchemy/compat/core14.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# software solely pursuant to the terms of the relevant commercial agreement.

import sqlalchemy as sa
from sqlalchemy.dialects.postgresql.base import PGCompiler
from sqlalchemy.sql import selectable
from sqlalchemy.sql.crud import (REQUIRED, _create_bind_param,
_extend_values_for_multiparams,
Expand All @@ -33,6 +34,12 @@

class CrateCompilerSA14(CrateCompiler):

def returning_clause(self, stmt, returning_cols):
"""
Generate RETURNING clause, PostgreSQL-compatible.
"""
return PGCompiler.returning_clause(self, stmt, returning_cols)

def visit_update(self, update_stmt, **kw):

compile_state = update_stmt._compile_state_factory(
Expand Down
6 changes: 0 additions & 6 deletions src/crate/client/sqlalchemy/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,6 @@ def visit_any(self, element, **kw):
self.process(element.right, **kw)
)

def returning_clause(self, stmt, returning_cols):
"""
Generate RETURNING clause, PostgreSQL-compatible.
"""
return PGCompiler.returning_clause(self, stmt, returning_cols)

def limit_clause(self, select, **kw):
"""
Generate OFFSET / LIMIT clause, PostgreSQL-compatible.
Expand Down

0 comments on commit dfcdd0f

Please sign in to comment.