Skip to content

Commit d28cac5

Browse files
authored
fix: avoid scribbling on (reused) bind param (#365)
Closes #357.
1 parent 7f1ce80 commit d28cac5

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

sqlalchemy_bigquery/base.py

+6
Original file line numberDiff line numberDiff line change
@@ -471,8 +471,14 @@ def visit_bindparam(
471471
# The NullType/known-type check has to do with some extreme
472472
# edge cases having to do with empty in-lists that get special
473473
# hijinks from SQLAlchemy that we don't want to disturb. :)
474+
#
475+
# Note that we do *not* want to overwrite the "real" bindparam
476+
# here, because then we can't do a recompile later (e.g., first
477+
# print the statment, then execute it). See issue #357.
478+
#
474479
if getattr(bindparam, "expand_op", None) is not None:
475480
assert bindparam.expand_op.__name__.endswith("in_op") # in in
481+
bindparam = bindparam._clone(maintain_key=True)
476482
bindparam.expanding = False
477483
unnest = True
478484

0 commit comments

Comments
 (0)