dumpdata should not use router.allow_migrate
|Reported by:||yscumc||Owned by:|
|Component:||Core (Management commands)||Version:||1.5|
|Cc:||Twidi, anubhav9042@…||Triage Stage:||Accepted|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
I have two databases with a router in place to prevent syncdb from automatically creating tables on the 2nd database (referred to as: second_database).
When manage.py dumpdata --database=second_database is executed, an empty JSON array is printed: 
if not model._meta.proxy and router.allow_syncdb(using, model):
For the dumpdata command to be dependent on the router.allow_syncdb() was totally unexpected because it is not documented anywhere and the name of the router method is allow_syncdb() which gives the impression that it only influences the syncdb command.
The allow_syncdb should ONLY affect syncdb and a separate method should be created for the dumpdata/loaddata commands. This would allow dumpdata to be run on a non-syncdb-able database.
Note: I do know there's a Managed = False meta option on each model and I could remove the allow_syncdb on my router as a workaround for my specific use case, but I still feel the current behavior is extremely counter-intuitive. Either the doc should be updated, or the alternative methods added to the router to determine the behavior for the other two non-syncdb commands.
Change History (10)
comment:1 Changed 2 years ago by yscumc
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
- Type changed from Uncategorized to Bug
comment:8 Changed 18 months ago by andersonresende
- Owner changed from nobody to andersonresende
- Status changed from new to assigned
comment:9 Changed 16 months ago by collinanderson
- Summary changed from dumpdata should not use router.allow_syncdb to dumpdata should not use router.allow_migrate