File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -197,18 +197,21 @@ def _substitute_named_or_pyformat_markers(self):
197
197
Raises a ``RuntimeError`` if any parameters are missing or unused.
198
198
"""
199
199
200
- unused_params = set ( self ._kwargs .keys ())
200
+ unused_params = { param_name : True for param_name in self ._kwargs .keys ()}
201
201
for token_index , param_name in self ._placeholders .items ():
202
202
if param_name not in self ._kwargs :
203
203
raise RuntimeError (f"missing value for placeholder ({ param_name } )" )
204
204
205
205
self ._tokens [token_index ] = self ._kwargs [param_name ]
206
- unused_params . remove ( param_name )
206
+ unused_params [ param_name ] = False
207
207
208
- if len (unused_params ) > 0 :
209
- joined_unused_params = get_human_readable_list (sorted (unused_params ))
208
+ sorted_unique_unused_param_names = sorted (set (
209
+ param_name for param_name , unused in unused_params .items () if unused ))
210
+ if len (sorted_unique_unused_param_names ) > 0 :
211
+ joined_unused_params = get_human_readable_list (sorted_unique_unused_param_names )
210
212
raise RuntimeError (
211
- f"unused value{ '' if len (unused_params ) == 1 else 's' } ({ joined_unused_params } )" )
213
+ f"unused value{ '' if len (sorted_unique_unused_param_names ) == 1 else 's' } "
214
+ + " ({joined_unused_params})" )
212
215
213
216
def _escape_verbatim_colons (self ):
214
217
"""Escapes verbatim colons from string literal and identifier tokens so they aren't treated
Original file line number Diff line number Diff line change @@ -223,6 +223,10 @@ def test_named(self):
223
223
self .assertEqual (self .db .execute ("SELECT * FROM foo" ), [{"firstname" : "bar" , "lastname" : "baz" }])
224
224
self .db .execute ("DELETE FROM foo" )
225
225
226
+ self .db .execute ("INSERT INTO foo VALUES (:baz, :baz)" , baz = "baz" )
227
+ self .assertEqual (self .db .execute ("SELECT * FROM foo" ), [{"firstname" : "baz" , "lastname" : "baz" }])
228
+ self .db .execute ("DELETE FROM foo" )
229
+
226
230
self .db .execute ("CREATE TABLE bar (firstname VARCHAR(255))" )
227
231
self .db .execute ("INSERT INTO bar VALUES (:baz)" , baz = "baz" )
228
232
self .assertEqual (self .db .execute ("SELECT * FROM bar" ), [{"firstname" : "baz" }])
You can’t perform that action at this time.
0 commit comments