#35429: Add argparse choices to --database options
-------------------------------------+-------------------------------------
     Reporter:  Adam Johnson         |                    Owner:  Jae Hyuck
         Type:                       |  Sa
  Cleanup/optimization               |                   Status:  assigned
    Component:  Core (Management     |                  Version:  dev
  commands)                          |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  1                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Comment (by Mariusz Felisiak):

 Replying to [ticket:35429 Adam Johnson]:
 > We can add [https://docs.python.org/3.12/library/argparse.html#choices
 argparse’s choices] for validation:
 >
 > {{{
 > --- django/core/management/commands/migrate.py
 > +++ django/core/management/commands/migrate.py
 > @@ -47,6 +47,7 @@ def add_arguments(self, parser):
 >          parser.add_argument(
 >              "--database",
 >              default=DEFAULT_DB_ALIAS,
 > +            choices=tuple(connections),
 >              help=(
 >                  'Nominates a database to synchronize. Defaults to the
 "default" '
 >                  "database."
 > }}}


 Can we? Do we really want to iterate over connections? As far as I'm
 aware, this will force initialization of all database connections. I don't
 think it's acceptable. IMO it's not worth doing.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/35429#comment:9>
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018f48834ec4-eca911e9-b63b-4954-9d69-f453e4b9aa48-000000%40eu-central-1.amazonses.com.

Reply via email to