File tree 3 files changed +38
-14
lines changed
3 files changed +38
-14
lines changed Original file line number Diff line number Diff line change @@ -227,10 +227,13 @@ def _compile_many(
227
227
compiled = queries [0 ].compile (
228
228
dialect = self ._dialect , compile_kwargs = {"render_postcompile" : True }
229
229
)
230
- for args in values :
231
- for key , val in args .items ():
232
- if key in compiled ._bind_processors :
233
- args [key ] = compiled ._bind_processors [key ](val )
230
+ if not isinstance (queries [0 ], DDLElement ):
231
+ for args in values :
232
+ for key , val in args .items ():
233
+ if key in compiled ._bind_processors :
234
+ args [key ] = compiled ._bind_processors [key ](val )
235
+ else :
236
+ values = []
234
237
return compiled .string , values
235
238
236
239
@property
Original file line number Diff line number Diff line change @@ -272,11 +272,24 @@ def _compile_many(
272
272
compiled = queries [0 ].compile (
273
273
dialect = self ._dialect , compile_kwargs = {"render_postcompile" : True }
274
274
)
275
- for args in values :
276
- for key , val in args .items ():
277
- if key in compiled ._bind_processors :
278
- args [key ] = compiled ._bind_processors [key ](val )
279
- return compiled .string , values
275
+ new_values = []
276
+ if not isinstance (queries [0 ], DDLElement ):
277
+ for args in values :
278
+ sorted_args = sorted (args .items ())
279
+ mapping = {
280
+ key : "$" + str (i ) for i , (key , _ ) in enumerate (sorted_args , start = 1 )
281
+ }
282
+ compiled_query = compiled .string % mapping
283
+ processors = compiled ._bind_processors
284
+ values = [
285
+ processors [key ](val ) if key in processors else val
286
+ for key , val in sorted_args
287
+ ]
288
+ new_values .append (values )
289
+ else :
290
+ compiled_query = compiled .string
291
+ new_values = []
292
+ return compiled_query , new_values
280
293
281
294
@staticmethod
282
295
def _create_column_maps (
Original file line number Diff line number Diff line change @@ -203,11 +203,19 @@ def _compile_many(
203
203
compiled = queries [0 ].compile (
204
204
dialect = self ._dialect , compile_kwargs = {"render_postcompile" : True }
205
205
)
206
- for args in values :
207
- for key , val in args .items ():
208
- if key in compiled ._bind_processors :
209
- args [key ] = compiled ._bind_processors [key ](val )
210
- return compiled .string , values
206
+ new_values = []
207
+ if not isinstance (queries [0 ], DDLElement ):
208
+ for args in values :
209
+ temp_arr = []
210
+ for key in compiled .positiontup :
211
+ raw_val = args [key ]
212
+ if key in compiled ._bind_processors :
213
+ val = compiled ._bind_processors [key ](raw_val )
214
+ else :
215
+ val = raw_val
216
+ temp_arr .append (val )
217
+ new_values .append (temp_arr )
218
+ return compiled .string , new_values
211
219
212
220
@property
213
221
def raw_connection (self ) -> aiosqlite .core .Connection :
You can’t perform that action at this time.
0 commit comments