Opened 4 years ago

Closed 4 years ago

#32501 closed New feature (fixed)

Add support for INSERT...RETURNING on SQLite 3.35+

Reported by: Mariusz Felisiak Owned by: Girish Sontakke
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: no Patch needs improvement: yes
Easy pickings: yes UI/UX: no

Description

Support for the RETURNING clause on INSERT statements is one of the headline features in SQLite 3.35.0 (pending), see changelog and docs. This will allow bulk_create() to retrieve primary keys on SQLite.

Follow up to #31403.

Change History (5)

comment:1 by Ian Foote, 4 years ago

Easy pickings: set

This should be an easy ORM starter ticket.

What will be required is adding an implementation of the return_insert_columns method to https://github.com/django/django/blob/main/django/db/backends/sqlite3/operations.py and an implementation of can_return_columns_from_insert and can_return_rows_from_bulk_insert to https://github.com/django/django/blob/main/django/db/backends/sqlite3/features.py. Reference implementations can be found in the corresponding files for other database backends.

There are some existing tests in https://github.com/django/django/blob/main/tests/queries/test_db_returning.py.

Last edited 4 years ago by Ian Foote (previous) (diff)

comment:2 by Mariusz Felisiak, 4 years ago

Triage Stage: Someday/MaybeAccepted

comment:3 by Girish Sontakke, 4 years ago

Owner: changed from nobody to Girish Sontakke
Status: newassigned

comment:4 by Mariusz Felisiak, 4 years ago

Has patch: set
Needs documentation: set
Patch needs improvement: set

comment:5 by Mariusz Felisiak <felisiak.mariusz@…>, 4 years ago

Resolution: fixed
Status: assignedclosed

In 98abc0c9:

Fixed #32501 -- Added support for returning fields from INSERT statements on SQLite 3.35+.

Note: See TracTickets for help on using tickets.
Back to Top