From d28cac5864f183c0ca503854973d837b17783d52 Mon Sep 17 00:00:00 2001 From: Tres Seaver Date: Tue, 26 Oct 2021 19:56:26 -0400 Subject: [PATCH] fix: avoid scribbling on (reused) bind param (#365) Closes #357. --- sqlalchemy_bigquery/base.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sqlalchemy_bigquery/base.py b/sqlalchemy_bigquery/base.py index 00901646..cbb0f8cc 100644 --- a/sqlalchemy_bigquery/base.py +++ b/sqlalchemy_bigquery/base.py @@ -471,8 +471,14 @@ def visit_bindparam( # The NullType/known-type check has to do with some extreme # edge cases having to do with empty in-lists that get special # hijinks from SQLAlchemy that we don't want to disturb. :) + # + # Note that we do *not* want to overwrite the "real" bindparam + # here, because then we can't do a recompile later (e.g., first + # print the statment, then execute it). See issue #357. + # if getattr(bindparam, "expand_op", None) is not None: assert bindparam.expand_op.__name__.endswith("in_op") # in in + bindparam = bindparam._clone(maintain_key=True) bindparam.expanding = False unnest = True