[Django] #34277: Add where clause in QuerySet.bulk_create() when update_conflicts=True

107 views
Skip to first unread message

Django

unread,
Jan 21, 2023, 5:34:48 AM1/21/23
to django-...@googlegroups.com
#34277: Add where clause in QuerySet.bulk_create() when update_conflicts=True
--------------------------------------------+------------------------
Reporter: Alain Delplanque | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 4.1
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
--------------------------------------------+------------------------
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
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/34277>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 23, 2023, 3:00:23 AM1/23/23
to django-...@googlegroups.com
#34277: Add where clause in QuerySet.bulk_create() when update_conflicts=True
-------------------------------------+-------------------------------------

Reporter: Alain Delplanque | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* cc: Chih Sean Hsu (added)
* type: Uncategorized => New feature
* version: 4.1 => dev
* component: Uncategorized => Database layer (models, ORM)
* stage: Unreviewed => Accepted


Comment:

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.

--
Ticket URL: <https://code.djangoproject.com/ticket/34277#comment:1>

Django

unread,
Jan 25, 2023, 8:36:11 AM1/25/23
to django-...@googlegroups.com
#34277: Add where clause in QuerySet.bulk_create() when update_conflicts=True
-------------------------------------+-------------------------------------
Reporter: Alain Delplanque | Owner: HAMA
| Barhamou
Type: New feature | Status: assigned

Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by HAMA Barhamou):

* owner: nobody => HAMA Barhamou
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/34277#comment:2>

Django

unread,
Jan 25, 2023, 8:53:07 AM1/25/23
to django-...@googlegroups.com
#34277: Add where clause in QuerySet.bulk_create() when update_conflicts=True
-------------------------------------+-------------------------------------
Reporter: Alain Delplanque | Owner: HAMA
| Barhamou
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by HAMA Barhamou):

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

--
Ticket URL: <https://code.djangoproject.com/ticket/34277#comment:3>

Django

unread,
Nov 23, 2023, 11:37:24 AM11/23/23
to django-...@googlegroups.com
#34277: Add where clause in QuerySet.bulk_create() when update_conflicts=True
-------------------------------------+-------------------------------------
Reporter: Alain Delplanque | Owner: HAMA
| Barhamou
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by HAMA Barhamou):

* cc: HAMA Barhamou (added)
* needs_docs: 0 => 1
* has_patch: 0 => 1


Comment:

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,

--
Ticket URL: <https://code.djangoproject.com/ticket/34277#comment:4>

Django

unread,
Dec 8, 2023, 1:04:12 PM12/8/23
to django-...@googlegroups.com
#34277: Add where clause in QuerySet.bulk_create() when update_conflicts=True
-------------------------------------+-------------------------------------
Reporter: Alain Delplanque | Owner: HAMA
| Barhamou
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by HAMA Barhamou):

* needs_docs: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/34277#comment:5>

Django

unread,
Dec 11, 2023, 5:42:06 AM12/11/23
to django-...@googlegroups.com
#34277: Add where clause in QuerySet.bulk_create() when update_conflicts=True
-------------------------------------+-------------------------------------
Reporter: Alain Delplanque | Owner: HAMA
| Barhamou
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/34277#comment:6>

Django

unread,
Dec 18, 2023, 2:25:24 PM12/18/23
to django-...@googlegroups.com
#34277: Add where clause in QuerySet.bulk_create() when update_conflicts=True
-------------------------------------+-------------------------------------
Reporter: Alain Delplanque | Owner: HAMA
| Barhamou
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by HAMA Barhamou):

* needs_better_patch: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/34277#comment:7>

Django

unread,
Dec 19, 2023, 6:03:06 AM12/19/23
to django-...@googlegroups.com
#34277: Add where clause in QuerySet.bulk_create() when update_conflicts=True
-------------------------------------+-------------------------------------
Reporter: Alain Delplanque | Owner: HAMA
| Barhamou
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* needs_better_patch: 0 => 1

* needs_docs: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/34277#comment:8>

Django

unread,
Dec 21, 2023, 6:36:27 PM12/21/23
to django-...@googlegroups.com
#34277: Add where clause in QuerySet.bulk_create() when update_conflicts=True
-------------------------------------+-------------------------------------
Reporter: Alain Delplanque | Owner: HAMA
| Barhamou
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by HAMA Barhamou):

* needs_better_patch: 1 => 0

* needs_docs: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/34277#comment:9>

Django

unread,
Dec 22, 2023, 12:43:22 AM12/22/23
to django-...@googlegroups.com
#34277: Add where clause in QuerySet.bulk_create() when update_conflicts=True
-------------------------------------+-------------------------------------
Reporter: Alain Delplanque | Owner: HAMA
| Barhamou
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* needs_better_patch: 0 => 1

* needs_tests: 0 => 1


* needs_docs: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/34277#comment:10>

Django

unread,
Dec 23, 2023, 7:20:40 AM12/23/23
to django-...@googlegroups.com
#34277: Add where clause in QuerySet.bulk_create() when update_conflicts=True
-------------------------------------+-------------------------------------
Reporter: Alain Delplanque | Owner: HAMA
| Barhamou
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by HAMA Barhamou):

* needs_better_patch: 1 => 0

* needs_tests: 1 => 0


* needs_docs: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/34277#comment:11>

Django

unread,
Jan 1, 2024, 9:59:24 AM1/1/24
to django-...@googlegroups.com
#34277: Add where clause in QuerySet.bulk_create() when update_conflicts=True
-------------------------------------+-------------------------------------
Reporter: Alain Delplanque | Owner: HAMA
| Barhamou
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by HAMA Barhamou):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/34277#comment:12>

Django

unread,
Jan 1, 2024, 3:59:24 PM1/1/24
to django-...@googlegroups.com
#34277: Add where clause in QuerySet.bulk_create() when update_conflicts=True
-------------------------------------+-------------------------------------
Reporter: Alain Delplanque | Owner: HAMA
| Barhamou
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by HAMA Barhamou):

* needs_better_patch: 1 => 0


Comment:

ready for another revision

--
Ticket URL: <https://code.djangoproject.com/ticket/34277#comment:13>

Django

unread,
Jan 5, 2024, 3:13:11 AM1/5/24
to django-...@googlegroups.com
#34277: Add where clause in QuerySet.bulk_create() when update_conflicts=True
-------------------------------------+-------------------------------------
Reporter: Alain Delplanque | Owner: HAMA
| Barhamou
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/34277#comment:14>

Django

unread,
Jan 7, 2024, 4:04:07 PM1/7/24
to django-...@googlegroups.com
#34277: Add where clause in QuerySet.bulk_create() when update_conflicts=True
-------------------------------------+-------------------------------------
Reporter: Alain Delplanque | Owner: HAMA
| Barhamou
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by HAMA Barhamou):

* needs_better_patch: 1 => 0


Comment:

ready for another revision

--
Ticket URL: <https://code.djangoproject.com/ticket/34277#comment:15>

Django

unread,
Jan 9, 2024, 5:24:04 AM1/9/24
to django-...@googlegroups.com
#34277: Add where clause in QuerySet.bulk_create() when update_conflicts=True
-------------------------------------+-------------------------------------
Reporter: Alain Delplanque | Owner: HAMA
| Barhamou
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/34277#comment:16>

Django

unread,
Jan 14, 2024, 6:45:51 PM1/14/24
to django-...@googlegroups.com
#34277: Add where clause in QuerySet.bulk_create() when update_conflicts=True
-------------------------------------+-------------------------------------
Reporter: Alain Delplanque | Owner: HAMA
| Barhamou
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by HAMA Barhamou):

* needs_better_patch: 1 => 0


Comment:

ready for another revision

--
Ticket URL: <https://code.djangoproject.com/ticket/34277#comment:17>

Django

unread,
Jan 16, 2024, 10:54:11 AM1/16/24
to django-...@googlegroups.com
#34277: Add where clause in QuerySet.bulk_create() when update_conflicts=True
-------------------------------------+-------------------------------------
Reporter: Alain Delplanque | Owner: HAMA
| Barhamou
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by HAMA Barhamou):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/34277#comment:18>

Django

unread,
Jan 16, 2024, 2:41:19 PM1/16/24
to django-...@googlegroups.com
#34277: Add where clause in QuerySet.bulk_create() when update_conflicts=True
-------------------------------------+-------------------------------------
Reporter: Alain Delplanque | Owner: HAMA
| Barhamou
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by HAMA Barhamou):

* needs_better_patch: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/34277#comment:19>

Django

unread,
Feb 5, 2024, 2:57:18 PM2/5/24
to django-...@googlegroups.com
#34277: Add where clause in QuerySet.bulk_create() when update_conflicts=True
-------------------------------------+-------------------------------------
Reporter: Alain Delplanque | Owner: HAMA
| Barhamou
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by bcail):

* needs_better_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/34277#comment:20>

Django

unread,
Mar 6, 2024, 3:49:36 AM3/6/24
to django-...@googlegroups.com
#34277: Add where clause in QuerySet.bulk_create() when update_conflicts=True
-------------------------------------+-------------------------------------
Reporter: Alain Delplanque | Owner: HAMA
| Barhamou
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by HAMA Barhamou):

* needs_better_patch: 1 => 0

Comment:

ready for another revision
--
Ticket URL: <https://code.djangoproject.com/ticket/34277#comment:21>

Django

unread,
Mar 12, 2024, 8:51:18 AM3/12/24
to django-...@googlegroups.com
#34277: Add where clause in QuerySet.bulk_create() when update_conflicts=True
-------------------------------------+-------------------------------------
Reporter: Alain Delplanque | Owner: HAMA
| Barhamou
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by HAMA Barhamou):

* needs_better_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/34277#comment:22>

Django

unread,
Mar 12, 2024, 11:57:57 AM3/12/24
to django-...@googlegroups.com
#34277: Add where clause in QuerySet.bulk_create() when update_conflicts=True
-------------------------------------+-------------------------------------
Reporter: Alain Delplanque | Owner: HAMA
| Barhamou
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by HAMA Barhamou):

* needs_better_patch: 1 => 0

Comment:

ready for another revision
--
Ticket URL: <https://code.djangoproject.com/ticket/34277#comment:23>

Django

unread,
Mar 12, 2024, 12:35:49 PM3/12/24
to django-...@googlegroups.com
#34277: Add where clause in QuerySet.bulk_create() when update_conflicts=True
-------------------------------------+-------------------------------------
Reporter: Alain Delplanque | Owner: HAMA
| Barhamou
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Natalia Bidart):

* needs_better_patch: 0 => 1

Comment:

Setting as patch needs improvement following a reviewer request to rebase
and squash commits to allow for/ease future review iterations.
--
Ticket URL: <https://code.djangoproject.com/ticket/34277#comment:24>

Django

unread,
Mar 13, 2024, 6:29:49 AM3/13/24
to django-...@googlegroups.com
#34277: Add where clause in QuerySet.bulk_create() when update_conflicts=True
-------------------------------------+-------------------------------------
Reporter: Alain Delplanque | Owner: HAMA
| Barhamou
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by HAMA Barhamou):

* needs_better_patch: 1 => 0

Comment:

ready for another revision
--
Ticket URL: <https://code.djangoproject.com/ticket/34277#comment:25>

Django

unread,
Apr 11, 2024, 6:31:26 AM4/11/24
to django-...@googlegroups.com
#34277: Add where clause in QuerySet.bulk_create() when update_conflicts=True
-------------------------------------+-------------------------------------
Reporter: Alain Delplanque | Owner: HAMA
| Barhamou
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* needs_better_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/34277#comment:26>

Django

unread,
Sep 27, 2025, 4:12:07 AM9/27/25
to django-...@googlegroups.com
#34277: Add where clause in QuerySet.bulk_create() when update_conflicts=True
-------------------------------------+-------------------------------------
Reporter: Alain Delplanque | Owner: HAMA
| Barhamou
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by HAMA Barhamou):

* needs_better_patch: 1 => 0

Comment:

ready for another revision
--
Ticket URL: <https://code.djangoproject.com/ticket/34277#comment:27>
Reply all
Reply to author
Forward
0 new messages