Opened 17 years ago
Closed 14 years ago
#7566 closed (fixed)
dumpdata command should not use model._default_manager.all()
Reported by: | anonymous | Owned by: | nobody |
---|---|---|---|
Component: | Core (Serialization) | Version: | dev |
Severity: | Keywords: | dumpdata | |
Cc: | Triage Stage: | Design decision needed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
dumpdata command should not use model._default_manager.all() for retrieving objects because model can use custom Manager with redefined .all() method.
better way for retrieving all objects is using QuerySet(model).all()
Attachments (2)
Change History (7)
by , 17 years ago
Attachment: | dumpdata-fix.patch added |
---|
by , 17 years ago
comment:1 by , 17 years ago
Triage Stage: | Unreviewed → Accepted |
---|
Seems like a good idea, since I'd expect you'd normally want to dump everything even if the default manager excludes some records. I was unaware of that syntax for QuerySet creation when the fix for #6155 went in. But if this change is made then the doc note about the default manager being used needs to be deleted, since it won't be true any more. I updated the patch to do that as well.
comment:2 by , 16 years ago
Triage Stage: | Accepted → Design decision needed |
---|
I'm -1 on this change. If you have installed a default manager it's because they're the records you consider the "whole set" by default. And that's what dumpdata works with. If you wanted the whole set to be "everything", you wouldn't have overridden the default manager.
follow-up: 4 comment:3 by , 16 years ago
Eh, for my case I don't think of what the default manager returns as the "whole set". It's more the publicly-visible set. There's more in the database (which existed long before I put a Django front-end on it) than I care to expose via the website front-end, and I use excluding default managers to limit what can be seen in the normal case via the web site. That said, I've never actually used dumpdata (I backup/migrate/move the DB with database utilities directly) so I'm not particularly qualified to comment on how it should behave. But if I did need to use it, I think I'd want it to dump all the data.
comment:4 by , 16 years ago
Replying to Karen Tracey <kmtracey@gmail.com>:
Eh, for my case I don't think of what the default manager returns as the "whole set". It's more the publicly-visible set. There's more in the database (which existed long before I put a Django front-end on it) than I care to expose via the website front-end, and I use excluding default managers to limit what can be seen in the normal case via the web site. That said, I've never actually used dumpdata (I backup/migrate/move the DB with database utilities directly) so I'm not particularly qualified to comment on how it should behave. But if I did need to use it, I think I'd want it to dump all the data.
I agree with Karen Tracey. I use custom manager for creating versions of object, they makes visible only last version. If i execute dumpdata, i expect that all objects will be saved. Creating new method for filtering objects eliminates the need for a possible replace of the Manager, because that need to change all of the related sources.
comment:5 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
This was fixed in r13669 with a Solomonic decision.
Patch that updates doc as well