Opened 14 years ago
Closed 14 years ago
#14437 closed (duplicate)
Allow force_insert for fixtures loading.
Reported by: | Piotr Czachur | Owned by: | nobody |
---|---|---|---|
Component: | Core (Serialization) | Version: | dev |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
There are some useful cases where silent overwriting is not desired: for example in unit testing, when you use multiple fixture files, and can duplicate PK by mistake. It has another advantage - django won't be checking if instance already exists in database, so test fixtures will load a bit faster.
This issue is not only connected with unit testing, I just give you practical example.
Note:
See TracTickets
for help on using tickets.
#14989 was a closely related report, with a slightly different presentation.
I'm not convinced the "duplicate PK over multiple fixtures" is a significant problem -- in fact, you can use the existing behavior to your advantage (fixture load order can be used to determine which objects override others).
The other interpretation of this ticket -- the "only insert if it doesn't already exist" use case -- is essentially the same as "only load initial_data on first run", which is covered by #9549. The use of force_insert is an implementation issue.
Closing as a duplicate of #9549.