|
22 | 22 | from django.utils.regex_helper import _lazy_re_compile |
23 | 23 |
|
24 | 24 | from .base import Database |
25 | | -from .utils import BulkInsertMapper, InsertVar, Oracle_datetime |
| 25 | +from .utils import BoundVar, BulkInsertMapper, Oracle_datetime |
26 | 26 |
|
27 | 27 |
|
28 | 28 | class DatabaseOperations(BaseDatabaseOperations): |
@@ -298,12 +298,27 @@ def convert_empty_bytes(value, expression, connection): |
298 | 298 | def deferrable_sql(self): |
299 | 299 | return " DEFERRABLE INITIALLY DEFERRED" |
300 | 300 |
|
301 | | - def fetch_returned_insert_columns(self, cursor, returning_params): |
302 | | - columns = [] |
303 | | - for param in returning_params: |
304 | | - value = param.get_value() |
305 | | - columns.append(value[0]) |
306 | | - return tuple(columns) |
| 301 | + def returning_columns(self, fields): |
| 302 | + if not fields: |
| 303 | + return "", () |
| 304 | + field_names = [] |
| 305 | + params = [] |
| 306 | + for field in fields: |
| 307 | + field_names.append( |
| 308 | + "%s.%s" |
| 309 | + % ( |
| 310 | + self.quote_name(field.model._meta.db_table), |
| 311 | + self.quote_name(field.column), |
| 312 | + ) |
| 313 | + ) |
| 314 | + params.append(BoundVar(field)) |
| 315 | + return "RETURNING %s INTO %s" % ( |
| 316 | + ", ".join(field_names), |
| 317 | + ", ".join(["%s"] * len(params)), |
| 318 | + ), tuple(params) |
| 319 | + |
| 320 | + def fetch_returned_rows(self, cursor, returning_params): |
| 321 | + return list(zip(*(param.get_value() for param in returning_params))) |
307 | 322 |
|
308 | 323 | def no_limit_value(self): |
309 | 324 | return None |
@@ -391,25 +406,6 @@ def regex_lookup(self, lookup_type): |
391 | 406 | match_option = "'i'" |
392 | 407 | return "REGEXP_LIKE(%%s, %%s, %s)" % match_option |
393 | 408 |
|
394 | | - def return_insert_columns(self, fields): |
395 | | - if not fields: |
396 | | - return "", () |
397 | | - field_names = [] |
398 | | - params = [] |
399 | | - for field in fields: |
400 | | - field_names.append( |
401 | | - "%s.%s" |
402 | | - % ( |
403 | | - self.quote_name(field.model._meta.db_table), |
404 | | - self.quote_name(field.column), |
405 | | - ) |
406 | | - ) |
407 | | - params.append(InsertVar(field)) |
408 | | - return "RETURNING %s INTO %s" % ( |
409 | | - ", ".join(field_names), |
410 | | - ", ".join(["%s"] * len(params)), |
411 | | - ), tuple(params) |
412 | | - |
413 | 409 | def __foreign_key_constraints(self, table_name, recursive): |
414 | 410 | with self.connection.cursor() as cursor: |
415 | 411 | if recursive: |
|
0 commit comments