Skip to content

Commit 6f2988e

Browse files
authored
Merge branch 'main' into fix-table-reflection
2 parents 4a006bf + 9e0b117 commit 6f2988e

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

samples/snippets/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
alembic==1.13.1
2-
certifi==2024.6.2
2+
certifi==2024.7.4
33
charset-normalizer==3.3.2
44
geoalchemy2==0.15.1
55
google-api-core[grpc]==2.19.0

sqlalchemy_bigquery/base.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,9 @@ def visit_regexp_match_op_binary(self, binary, operator, **kw):
579579
def visit_not_regexp_match_op_binary(self, binary, operator, **kw):
580580
return "NOT %s" % self.visit_regexp_match_op_binary(binary, operator, **kw)
581581

582+
def visit_mod_binary(self, binary, operator, **kw):
583+
return f"MOD({self.process(binary.left, **kw)}, {self.process(binary.right, **kw)})"
584+
582585

583586
class BigQueryTypeCompiler(GenericTypeCompiler):
584587
def visit_INTEGER(self, type_, **kw):
@@ -985,6 +988,7 @@ class BigQueryDialect(DefaultDialect):
985988
type_compiler = BigQueryTypeCompiler
986989
ddl_compiler = BigQueryDDLCompiler
987990
execution_ctx_cls = BigQueryExecutionContext
991+
cte_follows_insert = True
988992
supports_alter = False
989993
supports_comments = True
990994
inline_comments = True

tests/sqlalchemy_dialect_compliance/test_dialect_compliance.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -537,10 +537,6 @@ def test_round_trip_executemany(self, connection):
537537

538538

539539
class CTETest(_CTETest):
540-
@pytest.mark.skip("Can't use CTEs with insert")
541-
def test_insert_from_select_round_trip(self):
542-
pass
543-
544540
@pytest.mark.skip("Recusive CTEs aren't supported.")
545541
def test_select_recursive_round_trip(self):
546542
pass

tests/unit/test_select.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,3 +406,16 @@ def test_visit_not_regexp_match_op_binary(faux_conn):
406406
expected = "NOT REGEXP_CONTAINS(`table`.`foo`, %(foo_1:STRING)s)"
407407

408408
assert result == expected
409+
410+
411+
def test_visit_mod_binary(faux_conn):
412+
table = setup_table(
413+
faux_conn,
414+
"table",
415+
sqlalchemy.Column("foo", sqlalchemy.Integer),
416+
)
417+
sql_statement = table.c.foo % 2
418+
result = sql_statement.compile(faux_conn).string
419+
expected = "MOD(`table`.`foo`, %(foo_1:INT64)s)"
420+
421+
assert result == expected

0 commit comments

Comments
 (0)