Add where clause in QuerySet.bulk_create() when update_conflicts=True
To import objects from one database to another, it would be necessary to filter rows that are subject to an update. Which in plain sql looks like:
INSERT INTO my_table (field1, ...)
VALUES ...
ON CONFLICT (pk)
DO UPDATE SET field1 = EXCLUDED.field1, ...
WHERE lastupdated < EXCLUDED.lastupdated
Change History
(27)
Cc: |
Chih Sean Hsu added
|
Component: |
Uncategorized → Database layer (models, ORM)
|
Triage Stage: |
Unreviewed → Accepted
|
Type: |
Uncategorized → New feature
|
Version: |
4.1 → dev
|
Owner: |
changed from nobody to HAMA Barhamou
|
Status: |
new → assigned
|
Cc: |
HAMA Barhamou added
|
Has patch: |
set
|
Needs documentation: |
set
|
Needs documentation: |
unset
|
Patch needs improvement: |
set
|
Patch needs improvement: |
unset
|
Needs documentation: |
set
|
Patch needs improvement: |
set
|
Needs documentation: |
unset
|
Patch needs improvement: |
unset
|
Needs documentation: |
set
|
Needs tests: |
set
|
Patch needs improvement: |
set
|
Needs documentation: |
unset
|
Needs tests: |
unset
|
Patch needs improvement: |
unset
|
Patch needs improvement: |
set
|
Patch needs improvement: |
unset
|
Patch needs improvement: |
set
|
Patch needs improvement: |
unset
|
Patch needs improvement: |
set
|
Patch needs improvement: |
unset
|
Patch needs improvement: |
set
|
Patch needs improvement: |
unset
|
Patch needs improvement: |
set
|
Patch needs improvement: |
unset
|
Patch needs improvement: |
set
|
Patch needs improvement: |
unset
|
Patch needs improvement: |
set
|
Patch needs improvement: |
unset
|
Patch needs improvement: |
set
|
Patch needs improvement: |
unset
|
Thanks for the ticket (follow up to #31685). Looks like a nice addition, we need to remember that it's not supported on MySQL/MariaDB.