[Django] #31019: The database backend specific checks could be bypassed when using multiple databases with one empty default database.

6 views
Skip to first unread message

Django

unread,
Nov 21, 2019, 8:20:33 AM11/21/19
to django-...@googlegroups.com
#31019: The database backend specific checks could be bypassed when using multiple
databases with one empty default database.
------------------------------------------------+------------------------
Reporter: Shipeng Feng | Owner: nobody
Type: Bug | Status: new
Component: Core (System checks) | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------------+------------------------
Here is the settings:

{{{
#!python
DATABASES = {
'default': {},
'users': {
'NAME': 'user_data',
'ENGINE': 'django.db.backends.mysql',
'USER': 'mysql_user',
'PASSWORD': 'superS3cret'
},
'customers': {
'NAME': 'customer_data',
'ENGINE': 'django.db.backends.mysql',
'USER': 'mysql_cust',
'PASSWORD': 'veryPriv@ate'
}
}
}}}

Here is the related source code:
https://github.com/django/django/blob/f97a6123c07de5099fdf8b7d00ef7d20ed354e07/django/db/models/fields/__init__.py#L340

We only run checks for the first db, and the behavior of the first is
undetermined (the first entry of a dictionary),
if the first db is `default`, then we would only run dummy backend checks,
mysql checks are bypassed.

--
Ticket URL: <https://code.djangoproject.com/ticket/31019>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Nov 21, 2019, 8:23:53 AM11/21/19
to django-...@googlegroups.com
#31019: The database backend specific checks could be bypassed when using multiple
databases with one empty default database.
-------------------------------------+-------------------------------------

Reporter: Shipeng Feng | Owner: nobody
Type: Bug | Status: new
Component: Core (System | Version: master
checks) |
Severity: Normal | Resolution:

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Shipeng Feng:

Old description:

> Here is the settings:
>
> {{{
> #!python
> DATABASES = {
> 'default': {},
> 'users': {
> 'NAME': 'user_data',
> 'ENGINE': 'django.db.backends.mysql',
> 'USER': 'mysql_user',
> 'PASSWORD': 'superS3cret'
> },
> 'customers': {
> 'NAME': 'customer_data',
> 'ENGINE': 'django.db.backends.mysql',
> 'USER': 'mysql_cust',
> 'PASSWORD': 'veryPriv@ate'
> }
> }
> }}}
>
> Here is the related source code:
> https://github.com/django/django/blob/f97a6123c07de5099fdf8b7d00ef7d20ed354e07/django/db/models/fields/__init__.py#L340
>
> We only run checks for the first db, and the behavior of the first is
> undetermined (the first entry of a dictionary),
> if the first db is `default`, then we would only run dummy backend
> checks, mysql checks are bypassed.

New description:

Here is the settings:

{{{
#!python
DATABASES = {
'default': {},
'users': {
'NAME': 'user_data',
'ENGINE': 'django.db.backends.mysql',
'USER': 'mysql_user',
'PASSWORD': 'superS3cret'
},
}
}}}

Here is the related source code:
https://github.com/django/django/blob/f97a6123c07de5099fdf8b7d00ef7d20ed354e07/django/db/models/fields/__init__.py#L340

We only run checks for the first db, and the behavior of the first is
undetermined (the first entry of a dictionary),
if the first db is `default`, then we would only run dummy backend checks,
mysql checks are bypassed.

--

--
Ticket URL: <https://code.djangoproject.com/ticket/31019#comment:1>

Django

unread,
Nov 21, 2019, 8:24:21 AM11/21/19
to django-...@googlegroups.com
#31019: The database backend specific checks could be bypassed when using multiple
databases with one empty default database.
-------------------------------------+-------------------------------------

Reporter: Shipeng Feng | Owner: nobody
Type: Bug | Status: new
Component: Core (System | Version: master
checks) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Shipeng Feng:

Old description:

> Here is the settings:


>
> {{{
> #!python
> DATABASES = {
> 'default': {},
> 'users': {
> 'NAME': 'user_data',
> 'ENGINE': 'django.db.backends.mysql',
> 'USER': 'mysql_user',
> 'PASSWORD': 'superS3cret'
> },
> }
> }}}
>

> Here is the related source code:
> https://github.com/django/django/blob/f97a6123c07de5099fdf8b7d00ef7d20ed354e07/django/db/models/fields/__init__.py#L340
>
> We only run checks for the first db, and the behavior of the first is
> undetermined (the first entry of a dictionary),
> if the first db is `default`, then we would only run dummy backend
> checks, mysql checks are bypassed.

New description:

Here is the settings:

{{{
#!python
DATABASES = {
'default': {},
'users': {
'NAME': 'user_data',
'ENGINE': 'django.db.backends.mysql',
'USER': 'mysql_user',
'PASSWORD': 'superS3cret'
},
}
}}}

Here is the related source code:
https://github.com/django/django/blob/f97a6123c07de5099fdf8b7d00ef7d20ed354e07/django/db/models/fields/__init__.py#L340

We only run checks for the first db, and the behavior of the first db is


undetermined (the first entry of a dictionary),
if the first db is `default`, then we would only run dummy backend checks,
mysql checks are bypassed.

--

--
Ticket URL: <https://code.djangoproject.com/ticket/31019#comment:2>

Django

unread,
Nov 21, 2019, 8:32:55 AM11/21/19
to django-...@googlegroups.com
#31019: The database backend specific checks could be bypassed when using multiple
databases.
-------------------------------------+-------------------------------------

Reporter: Shipeng Feng | Owner: nobody
Type: Bug | Status: closed

Component: Core (System | Version: master
checks) |
Severity: Normal | Resolution: invalid

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* status: new => closed
* resolution: => invalid


Comment:

You're router should define
[https://docs.djangoproject.com/en/2.2/topics/db/multi-db/#allow_migrate
allow_migrate()] method that will return `True` only for the `customer`
db.


Closing per TicketClosingReasons/UseSupportChannels.

--
Ticket URL: <https://code.djangoproject.com/ticket/31019#comment:3>

Django

unread,
Nov 21, 2019, 9:45:49 PM11/21/19
to django-...@googlegroups.com
#31019: The database backend specific checks could be bypassed when using multiple
databases.
-------------------------------------+-------------------------------------

Reporter: Shipeng Feng | Owner: nobody
Type: Bug | Status: closed
Component: Core (System | Version: master
checks) |
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Shipeng Feng):

I couldn't find any documentation for this, is this documented anywhere?
Or we could add some notices about this in the documentation
so that others won't encounter the same problem.

--
Ticket URL: <https://code.djangoproject.com/ticket/31019#comment:4>

Django

unread,
Nov 22, 2019, 1:59:11 AM11/22/19
to django-...@googlegroups.com
#31019: The database backend specific checks could be bypassed when using multiple
databases.
-------------------------------------+-------------------------------------

Reporter: Shipeng Feng | Owner: nobody
Type: Bug | Status: closed
Component: Core (System | Version: master
checks) |
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by felixxm):

`allow_migrate()` is [https://docs.djangoproject.com/en/2.2/topics/db
/multi-db/#allow_migrate documented] also you should also read carefully
the entire [https://docs.djangoproject.com/en/2.2/topics/db/multi-db
Multiple databases topic].

--
Ticket URL: <https://code.djangoproject.com/ticket/31019#comment:5>

Reply all
Reply to author
Forward
0 new messages