New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refs #21906 -- Changed dumpdata --database default to router.db_for_read. #12718
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hramezani Thanks for this patch 👍 IMO we should change loaddata
in the same commit, because changing only dumpdata
will make this scenario even more error prone.
@@ -32,7 +32,7 @@ def add_arguments(self, parser): | |||
) | |||
parser.add_argument( | |||
'--database', | |||
default=DEFAULT_DB_ALIAS, | |||
default=None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update help
.
if not model._meta.proxy and router.allow_migrate_model(using, model): | ||
_using = using | ||
if _using is None: | ||
_using = router.db_for_read(model) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would change
index df9eecc0f8..953f261ef4 100644
--- a/django/core/management/commands/dumpdata.py
+++ b/django/core/management/commands/dumpdata.py
@@ -67,7 +67,7 @@ class Command(BaseCommand):
def handle(self, *app_labels, **options):
format = options['format']
indent = options['indent']
- using = options['database']
+ database = options['database']
excludes = options['exclude']
output = options['output']
show_traceback = options['traceback']
to simplify this.
We should also skip models with different db
for read, instead of checking router.allow_migrate_model()
, e.g.
using = router.db_for_read(model)
if not model._meta.proxy and (not database or using == database):
if use_base_manager:
...
@@ -320,6 +320,8 @@ Management Commands | |||
* The new :option:`dbshell -- ARGUMENTS <dbshell -->` option allows passing | |||
extra arguments to the command-line client for the database. | |||
|
|||
* The default for :option:`dumpdata --database` changed to :meth:`db_for_read`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should go to the Backwards incompatible changes
.
@felixxm Thanks for the review.
I take a look at
In general, I would say the I am eager to finish it, so If you have any idea it would be appreciated. Thanks |
@hramezani IMO these changes cannot be implemented separately, because we will create an option to dump data from multiple databases but they will be useless for
I will try to ask for opinions/ideas on the mailing list. |
@hramezani "I will try to ask ..." -> "I would try to ask ..." 😄 |
Ticket 21906.