Opened 16 months ago

Last modified 3 weeks ago

#34277 assigned New feature

Add where clause in QuerySet.bulk_create() when update_conflicts=True

Reported by: Alain Delplanque Owned by: HAMA Barhamou
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords:
Cc: Chih Sean Hsu, HAMA Barhamou Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

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 (26)

comment:1 by Mariusz Felisiak, 16 months ago

Cc: Chih Sean Hsu added
Component: UncategorizedDatabase layer (models, ORM)
Triage Stage: UnreviewedAccepted
Type: UncategorizedNew feature
Version: 4.1dev

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.

comment:2 by HAMA Barhamou, 15 months ago

Owner: changed from nobody to HAMA Barhamou
Status: newassigned

comment:3 by HAMA Barhamou, 15 months ago

Thank you for the ticket. I will work on it.
I'm new to this, so your advice would be appreciated.

comment:4 by HAMA Barhamou, 5 months ago

Cc: HAMA Barhamou added
Has patch: set
Needs documentation: set

Hello everyone,

I am excited to share that I have worked on implementing the feature requested in this ticket and have submitted a pull request for review. You can view and provide feedback or suggestions here: https://github.com/django/django/pull/17515.

Any comments or suggestions for improving the contribution are welcome. Thank you for the opportunity to contribute to Django, and I look forward to your feedback!

Best regards,

comment:5 by HAMA Barhamou, 5 months ago

Needs documentation: unset

comment:6 by Mariusz Felisiak, 5 months ago

Patch needs improvement: set

comment:7 by HAMA Barhamou, 5 months ago

Patch needs improvement: unset

comment:8 by Mariusz Felisiak, 5 months ago

Needs documentation: set
Patch needs improvement: set

comment:9 by HAMA Barhamou, 4 months ago

Needs documentation: unset
Patch needs improvement: unset

comment:10 by Mariusz Felisiak, 4 months ago

Needs documentation: set
Needs tests: set
Patch needs improvement: set

comment:11 by HAMA Barhamou, 4 months ago

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset

comment:12 by HAMA Barhamou, 4 months ago

Patch needs improvement: set

comment:13 by HAMA Barhamou, 4 months ago

Patch needs improvement: unset

ready for another revision

comment:14 by Sarah Boyce, 4 months ago

Patch needs improvement: set

comment:15 by HAMA Barhamou, 4 months ago

Patch needs improvement: unset

ready for another revision

comment:16 by Sarah Boyce, 4 months ago

Patch needs improvement: set

comment:17 by HAMA Barhamou, 4 months ago

Patch needs improvement: unset

ready for another revision

comment:18 by HAMA Barhamou, 4 months ago

Patch needs improvement: set

comment:19 by HAMA Barhamou, 4 months ago

Patch needs improvement: unset

comment:20 by bcail, 3 months ago

Patch needs improvement: set

comment:21 by HAMA Barhamou, 2 months ago

Patch needs improvement: unset

ready for another revision

comment:22 by HAMA Barhamou, 8 weeks ago

Patch needs improvement: set

comment:23 by HAMA Barhamou, 8 weeks ago

Patch needs improvement: unset

ready for another revision

comment:24 by Natalia Bidart, 8 weeks ago

Patch needs improvement: set

Setting as patch needs improvement following a reviewer request to rebase and squash commits to allow for/ease future review iterations.

comment:25 by HAMA Barhamou, 7 weeks ago

Patch needs improvement: unset

ready for another revision

comment:26 by Sarah Boyce, 3 weeks ago

Patch needs improvement: set
Note: See TracTickets for help on using tickets.
Back to Top