Greetings,
one problem that turns up more and more frequently, it seems, is that
someone is trying to run tests but can't because of the following scenario:
1. The user they connect to the DB using a role that does NOT have
permission to create a DB
2. Django's PG adapter, when keepdb is not set, will attempt to create
the DB
3. If the create fails, and NOT with the error of "duplicate DB name",
KABOOM.
The error they get is that the user does not have permission to create
DBs, since permissions are checked before testing if the name exists.
Instead, I'm trying to leverage the existing _database_exists check used
by keepdb.
My initial attempt checked if the DB exists and, if it does, issues a
"DROP OWNED BY CURRENT_USER;" instead of calling _execute_create_test_db.
Of course, this failed the tests, and rightly so. This obliterates the
protection of connecting to the wrong DB... and, in fact, makes that
mistake far FAR more damaging.
So I'm looking for input on what might be the best direction moving forward:
1. wrangle a new option to say "use existing" ... to allow using an
existing DB if it exists.
2. prompt the user to confirm they want to use the existing DB... and
perhaps prompt a second time to confirm they want to DROP OWNED BY...
3. some other option?
The first option, at least, will possibly require more invasive changes,
since higher levels of the code make assumptions about
_execute_create_test_db and when it will succeed / raise exception.
--
Curtis
--
You received this message because you are subscribed to the Google Groups "Django
developers (Contributions to Django itself)" 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].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-developers/3b1324e9-c3c1-6ae6-491b-3c9d9c5be47f%40tinbrain.net.
For more options, visit https://groups.google.com/d/optout.