|
@@ -76,6 +76,13 @@ class DatabaseOperations(BaseDatabaseOperations):
|
|
|
"""
|
|
|
return "django_date_extract('%s', %s)" % (lookup_type.lower(), field_name)
|
|
|
|
|
|
+ def fetch_returned_insert_rows(self, cursor):
|
|
|
+ """
|
|
|
+ Given a cursor object that has just performed an INSERT...RETURNING
|
|
|
+ statement into a table, return the list of returned data.
|
|
|
+ """
|
|
|
+ return cursor.fetchall()
|
|
|
+
|
|
|
def format_for_duration_arithmetic(self, sql):
|
|
|
"""Do nothing since formatting is handled in the custom function."""
|
|
|
return sql
|
|
@@ -365,3 +372,15 @@ class DatabaseOperations(BaseDatabaseOperations):
|
|
|
|
|
|
def insert_statement(self, ignore_conflicts=False):
|
|
|
return 'INSERT OR IGNORE INTO' if ignore_conflicts else super().insert_statement(ignore_conflicts)
|
|
|
+
|
|
|
+ def return_insert_columns(self, fields):
|
|
|
+ # SQLite < 3.35 doesn't support an INSERT...RETURNING statement.
|
|
|
+ if not fields:
|
|
|
+ return '', ()
|
|
|
+ columns = [
|
|
|
+ '%s.%s' % (
|
|
|
+ self.quote_name(field.model._meta.db_table),
|
|
|
+ self.quote_name(field.column),
|
|
|
+ ) for field in fields
|
|
|
+ ]
|
|
|
+ return 'RETURNING %s' % ', '.join(columns), ()
|