Skip to content

Commit 4c54416

Browse files
committed
fix: use statement.copy() to avoid protected attribute access
Fixes pyright reportPrivateUsage error by using the public copy() API instead of directly accessing _named_parameters and _positional_parameters.
1 parent be8437f commit 4c54416

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

sqlspec/driver/_common.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,12 +1363,9 @@ def _get_compiled_statement(
13631363
if params is not None and not isinstance(params, (list, tuple, dict)):
13641364
try:
13651365
materialized = list(params)
1366-
# Update the statement's internal parameters with materialized values
1367-
if statement._named_parameters:
1368-
# Named parameters are stored as dict, shouldn't be an iterator
1369-
pass
1370-
else:
1371-
statement._positional_parameters = materialized
1366+
# Create a copy of the statement with materialized parameters
1367+
# to avoid consuming the iterator during cache key generation
1368+
statement = statement.copy(parameters=materialized)
13721369
except TypeError:
13731370
pass # Not iterable, proceed normally
13741371

0 commit comments

Comments
 (0)