#21906: dumpdata should not use router.allow_syncdb
--------------------------------------------+--------------------
     Reporter:  yscumc                      |      Owner:  nobody
         Type:  Uncategorized               |     Status:  new
    Component:  Core (Management commands)  |    Version:  1.5
     Severity:  Normal                      |   Keywords:
 Triage Stage:  Unreviewed                  |  Has patch:  0
Easy pickings:  0                           |      UI/UX:  0
--------------------------------------------+--------------------
 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: `[]`

 Upon a lot of fumbling around, it seems that this behavior is caused by
 ticket #13308 in
 
[[https://github.com/django/django/commit/7b47609629692241848469fabc24fa798c0ac70b|this
 commit]].

 {{{
                 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.

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

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/049.0f3c7eb3076820030c6a948a34c0b628%40djangoproject.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to