#29043: test --keepdb says "Using existing test database" even if it's run for 
the
first time
-------------------------------------+-------------------------------------
     Reporter:  karyon               |                    Owner:  Hasan
         Type:                       |  Ramezani
  Cleanup/optimization               |                   Status:  assigned
    Component:  Database layer       |                  Version:  2.0
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  1
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Hasan Ramezani):

 @Carlton Gibson, Thanks for the comment.

 I checked Django database backends `creation.py` and the exception in
 `_execute_create_test_db()` just raise in `base` and `MySQL` backend.
 In `Postgres` backend, it checks the database assistance and doesn't raise
 an exception:
 ```
 {{{
     def _execute_create_test_db(self, cursor, parameters, keepdb=False):
         try:
             if keepdb and self._database_exists(cursor,
 parameters['dbname']):
                 # If the database should be kept and it already exists,
 don't
                 # try to create a new one.
                 return
 }}}

 In `Oracle ` backend we don't have the `_execute_create_test_db()`, Oracle
 backend has it's own `_create_test_db` and doesn't call the
 `_execute_create_test_db()`.

 So, it seems your proposed solution
 `
     Maybe we could add some additional output in the if keepdb branch
 there, just to clarify the existing message.
 '
 will add extra code but less than my first solution.

 I have another idea, we can clarify the message at the first point. here
 is the solution:

 {{{
 diff --git a/django/db/backends/base/creation.py
 b/django/db/backends/base/creation.py
 index f36d60a5fe..cdf092967a 100644
 --- a/django/db/backends/base/creation.py
 +++ b/django/db/backends/base/creation.py
 @@ -45,9 +45,10 @@ class BaseDatabaseCreation:
              if keepdb:
                  action = "Using existing"

 -            self.log('%s test database for alias %s...' % (
 +            self.log('%s test database for alias %s%s...' % (
                  action,
                  self._get_database_display_str(verbosity,
 test_database_name),
 +                '(if exists)' if keepdb else '',
              ))

          # We could skip this call if keepdb is True, but we instead

 }}}


 What is your opinion about this?

-- 
Ticket URL: <https://code.djangoproject.com/ticket/29043#comment:6>
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.25cc3d777017143f3e62f4499a6cf5d1%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to