[Django] #32224: SQLite3 bad filepath raising as JSON extension error

21 views
Skip to first unread message

Django

unread,
Nov 24, 2020, 10:07:11 AM11/24/20
to django-...@googlegroups.com
#32224: SQLite3 bad filepath raising as JSON extension error
------------------------------------------------+------------------------
Reporter: Juan | Owner: nobody
Type: Bug | Status: new
Component: Core (System checks) | Version: 3.1
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
------------------------------------------------+------------------------
Applying migrations on an installation using spatialite backend (probably
sqlite too) where the path to the database file does not exist causes a
confusing JSON field error.

Take this following DATABASES configuration. Note that the `dev.sqlite3`
file does not exist.

{{{
DATABASES = {
'default': {
'ENGINE': 'django.contrib.gis.db.backends.spatialite',
'NAME': '/home/user/app/dev.sqlite3',
}
}
}}}

When running `./manage.py migrate` the following exception is raised

{{{
SystemCheckError: System check identified some issues:

ERRORS:
rumble_common.RumbleEvent: (fields.E180) SQLite does not support
JSONFields.
}}}

We assert the JSON extension is present with the following code block, as
per [https://code.djangoproject.com/wiki/JSON1Extension]
{{{
>>> import sqlite3
>>> conn = sqlite3.connect(':memory:')
>>> cursor = conn.cursor()
>>> cursor.execute('SELECT JSON(\'{"a": "b"}\')')
}}}

The issue is resolved by changing
{{{
DATABASES['default']['NAME']
}}}
to point to the right path.

The issue is that the error is misleading, and leads developers down the
wrong rabbit hole

Hope thats descriptive enough, thanks all!

Extra:
Django 3.1.3
Debian Buster Docker environment

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

Django

unread,
Nov 24, 2020, 12:09:13 PM11/24/20
to django-...@googlegroups.com
#32224: SQLite3 bad filepath raising as JSON extension error.
-------------------------------------+-------------------------------------
Reporter: Juan Garcia Alvite | Owner: Mariusz
| Felisiak
Type: Bug | Status: assigned
Component: Database layer | Version: 3.1
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: new => assigned
* severity: Normal => Release blocker
* cc: sage (added)
* component: Core (System checks) => Database layer (models, ORM)
* owner: nobody => Mariusz Felisiak
* stage: Unreviewed => Accepted


Comment:

Thanks for the report.

Regression in 6789ded0a6ab797f0dcdfa6ad5d1cfa46e23abcd.
Reproduced at c70cd2a926ffab47f6613e83e0c8828eb6c2c064.

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

Django

unread,
Nov 24, 2020, 4:04:10 PM11/24/20
to django-...@googlegroups.com
#32224: SQLite3 bad filepath raising as JSON extension error.
-------------------------------------+-------------------------------------
Reporter: Juan Garcia Alvite | Owner: Mariusz
| Felisiak
Type: Bug | Status: assigned
Component: Database layer | Version: 3.1
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* has_patch: 0 => 1


Comment:

[https://github.com/django/django/pull/13714 PR]

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

Django

unread,
Nov 25, 2020, 2:55:30 AM11/25/20
to django-...@googlegroups.com
#32224: SQLite3 bad filepath raising as JSON extension error.
-------------------------------------+-------------------------------------
Reporter: Juan Garcia Alvite | Owner: Mariusz
| Felisiak
Type: Bug | Status: assigned
Component: Database layer | Version: 3.1
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* stage: Accepted => Ready for checkin


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

Django

unread,
Nov 25, 2020, 6:20:35 AM11/25/20
to django-...@googlegroups.com
#32224: SQLite3 bad filepath raising as JSON extension error.
-------------------------------------+-------------------------------------
Reporter: Juan Garcia Alvite | Owner: Mariusz
| Felisiak
Type: Bug | Status: closed

Component: Database layer | Version: 3.1
(models, ORM) |
Severity: Release blocker | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by GitHub <noreply@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"f5e5aac59ebbcea46b98d37834915de0f43d7cc8" f5e5aac5]:
{{{
#!CommitTicketReference repository=""
revision="f5e5aac59ebbcea46b98d37834915de0f43d7cc8"
Fixed #32224 -- Avoided suppressing connection errors in
supports_json_field on SQLite.`

Regression in 6789ded0a6ab797f0dcdfa6ad5d1cfa46e23abcd.

Thanks Juan Garcia Alvite for the report.
}}}

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

Django

unread,
Nov 25, 2020, 6:21:58 AM11/25/20
to django-...@googlegroups.com
#32224: SQLite3 bad filepath raising as JSON extension error.
-------------------------------------+-------------------------------------
Reporter: Juan Garcia Alvite | Owner: Mariusz
| Felisiak
Type: Bug | Status: closed
Component: Database layer | Version: 3.1
(models, ORM) |
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"97bfe0cba55720802abc7a7190ccb1ac575da50d" 97bfe0c]:
{{{
#!CommitTicketReference repository=""
revision="97bfe0cba55720802abc7a7190ccb1ac575da50d"
[3.1.x] Fixed #32224 -- Avoided suppressing connection errors in
supports_json_field on SQLite.

Regression in 6789ded0a6ab797f0dcdfa6ad5d1cfa46e23abcd.

Thanks Juan Garcia Alvite for the report.

Backport of f5e5aac59ebbcea46b98d37834915de0f43d7cc8 from master
}}}

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

Reply all
Reply to author
Forward
0 new messages