#16752: Multi-db without a 'default' database
-------------------------------------+-------------------------------------
Reporter: Jeremy Dunck | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.3
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Anton Samarchyan:
Old description:
> In the [https://docs.djangoproject.com/en/dev/topics/db/multi-db multi-db
> doc] it says:
> {{{
> If you don’t have a default database, you need to be careful to always
> specify the database that you want to use.
> }}}
>
> I have a project where that is exactly the behavior I'd prefer - I want
> to explicitly route every call and have nothing go to the 'default'
> database.
>
> However, when I removed the 'default' key from DATABASES (and hard-coded
> a router to always return a different value), model validation failed.
> This seems to be because it imports
> {{{
> from django.db import connection
> }}}
> then proceeds to validation the schema against that connection (which is,
> in fact, the non-existant 'default'). This fails as soon as an operation
> is called on the connection.
>
> There is a second problem with this -- all model validation occurs
> against the default connection rather than the connection that the model
> will be routed to. That seems like a bug, but I'd like to treat it
> separately.
>
> My intention with this ticket is to establish: do we intend projects to
> work without a 'default' project, as implied by the docs, or is a
> 'default' database always assumed?
New description:
In the [https://docs.djangoproject.com/en/dev/topics/db/multi-db multi-db
doc] it says:
{{{
If you don’t have a default database, you need to be careful to always
specify the database that you want to use.
}}}
I have a project where that is exactly the behavior I'd prefer - I want to
explicitly route every call and have nothing go to the 'default' database.
However, when I removed the 'default' key from DATABASES (and hard-coded a
router to always return a different value), model validation failed. This
seems to be because it imports
{{{
from django.db import connection
}}}
then proceeds to validation the schema against that connection (which is,
in fact, the nonexistent 'default'). This fails as soon as an operation
is called on the connection.
There is a second problem with this -- all model validation occurs against
the default connection rather than the connection that the model will be
routed to. That seems like a bug, but I'd like to treat it separately.
My intention with this ticket is to establish: do we intend projects to
work without a 'default' project, as implied by the docs, or is a
'default' database always assumed?
--
--
Ticket URL: <https://code.djangoproject.com/ticket/16752#comment:4>
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.7a4e9a152c171e7bfe08db70daf16cac%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.