Opened 3 years ago
Last modified 31 hours 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: | no |
| 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 (29)
comment:1 by , 3 years ago
| Cc: | added |
|---|---|
| Component: | Uncategorized → Database layer (models, ORM) |
| Triage Stage: | Unreviewed → Accepted |
| Type: | Uncategorized → New feature |
| Version: | 4.1 → dev |
comment:2 by , 3 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
comment:3 by , 3 years 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 , 3 years ago
| Cc: | 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 , 3 years ago
| Needs documentation: | unset |
|---|
comment:6 by , 3 years ago
| Patch needs improvement: | set |
|---|
comment:7 by , 3 years ago
| Patch needs improvement: | unset |
|---|
comment:8 by , 3 years ago
| Needs documentation: | set |
|---|---|
| Patch needs improvement: | set |
comment:9 by , 3 years ago
| Needs documentation: | unset |
|---|---|
| Patch needs improvement: | unset |
comment:10 by , 3 years ago
| Needs documentation: | set |
|---|---|
| Needs tests: | set |
| Patch needs improvement: | set |
comment:11 by , 3 years ago
| Needs documentation: | unset |
|---|---|
| Needs tests: | unset |
| Patch needs improvement: | unset |
comment:12 by , 3 years ago
| Patch needs improvement: | set |
|---|
comment:14 by , 3 years ago
| Patch needs improvement: | set |
|---|
comment:16 by , 3 years ago
| Patch needs improvement: | set |
|---|
comment:18 by , 3 years ago
| Patch needs improvement: | set |
|---|
comment:19 by , 3 years ago
| Patch needs improvement: | unset |
|---|
comment:20 by , 2 years ago
| Patch needs improvement: | set |
|---|
comment:22 by , 2 years ago
| Patch needs improvement: | set |
|---|
comment:24 by , 2 years 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:26 by , 2 years ago
| Patch needs improvement: | set |
|---|
comment:28 by , 2 days ago
| Patch needs improvement: | set |
|---|
It didn't make it in the 6.1 window, so the PR needs to be targeted at 6.2 now. Hopefully you still have the energy, this can get done!
comment:29 by , 31 hours ago
| Patch needs improvement: | unset |
|---|
Patch still applies cleanly, needs a review.
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.