Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 65d676d

Browse filesBrowse files
committed
move bindparam workaround to visit_JSON
1 parent d0fd734 commit 65d676d
Copy full SHA for 65d676d

File tree

1 file changed

+9
-4
lines changed
Filter options

1 file changed

+9
-4
lines changed

‎sqlalchemy_bigquery/base.py

Copy file name to clipboardExpand all lines: sqlalchemy_bigquery/base.py
+9-4Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -548,10 +548,7 @@ def visit_bindparam(
548548
bq_type = self.__remove_type_parameter(bq_type)
549549

550550
if bq_type == "JSON":
551-
# FIXME: JSON is not a member of `SqlParameterScalarTypes` in the DBAPI
552-
# For now, we hack around this by:
553-
# - Rewriting the bindparam type to STRING
554-
# - Applying a bind expression that converts the parameter back to JSON
551+
555552
bq_type = "STRING"
556553

557554
assert_(param != "%s", f"Unexpected param: {param}")
@@ -649,6 +646,14 @@ def visit_NUMERIC(self, type_, **kw):
649646
visit_DECIMAL = visit_NUMERIC
650647

651648
def visit_JSON(self, type_, **kw):
649+
if isinstance(
650+
kw.get("type_expression"), sqlalchemy.sql.expression.BindParameter
651+
): # bindparam
652+
# FIXME: JSON is not a member of `SqlParameterScalarTypes` in the DBAPI
653+
# For now, we hack around this by:
654+
# - Rewriting the bindparam type to STRING
655+
# - Applying a bind expression that converts the parameter back to JSON
656+
return "STRING"
652657
return "JSON"
653658

654659

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.