@@ -255,8 +255,6 @@ def execute(self, query, params=None, with_column_types=False,
255
255
Defaults to ``False`` (row-like form).
256
256
257
257
:return: * number of inserted rows for INSERT queries with data.
258
- Returning rows count from INSERT FROM SELECT is not
259
- supported.
260
258
* if `with_column_types=False`: `list` of `tuples` with
261
259
rows/columns.
262
260
* if `with_column_types=True`: `tuple` of 2 elements:
@@ -284,11 +282,23 @@ def execute(self, query, params=None, with_column_types=False,
284
282
)
285
283
else :
286
284
rv = self .process_ordinary_query (
287
- query , params = params , with_column_types = with_column_types ,
285
+ query , params = params , with_column_types = True ,
288
286
external_tables = external_tables ,
289
287
query_id = query_id , types_check = types_check ,
290
288
columnar = columnar
291
289
)
290
+ rows , columns_with_types = rv
291
+ # No columns in case of DDL or INSERT ... SELECT
292
+ if not columns_with_types :
293
+ # Dump check for INSERT.
294
+ # Backwards compatibility for .execute(DDL) return [].
295
+ # TODO: remove in 0.3.0. Return integer (zero) for DDL too.
296
+ if query .lower ().strip ().startswith ('insert' ):
297
+ rows = self .last_query .progress .rows
298
+ rv = (rows , columns_with_types )
299
+ if not with_column_types :
300
+ rv = rv [0 ]
301
+
292
302
self .last_query .store_elapsed (time () - start_time )
293
303
return rv
294
304
0 commit comments