Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#32224 closed Bug (fixed)

SQLite3 bad filepath raising as JSON extension error.

Reported by: Juan Garcia Alvite Owned by: Mariusz Felisiak
Component: Database layer (models, ORM) Version: 3.1
Severity: Release blocker Keywords:
Cc: Sage Abdullah Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

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

Change History (5)

comment:1 by Mariusz Felisiak, 3 years ago

Cc: Sage Abdullah added
Component: Core (System checks)Database layer (models, ORM)
Owner: changed from nobody to Mariusz Felisiak
Severity: NormalRelease blocker
Status: newassigned
Summary: SQLite3 bad filepath raising as JSON extension errorSQLite3 bad filepath raising as JSON extension error.
Triage Stage: UnreviewedAccepted

Thanks for the report.

Regression in 6789ded0a6ab797f0dcdfa6ad5d1cfa46e23abcd.
Reproduced at c70cd2a926ffab47f6613e83e0c8828eb6c2c064.

comment:2 by Mariusz Felisiak, 3 years ago

Has patch: set

comment:3 by Carlton Gibson, 3 years ago

Triage Stage: AcceptedReady for checkin

comment:4 by GitHub <noreply@…>, 3 years ago

Resolution: fixed
Status: assignedclosed

In f5e5aac5:

Fixed #32224 -- Avoided suppressing connection errors in supports_json_field on SQLite.`

Regression in 6789ded0a6ab797f0dcdfa6ad5d1cfa46e23abcd.

Thanks Juan Garcia Alvite for the report.

comment:5 by Mariusz Felisiak <felisiak.mariusz@…>, 3 years ago

In 97bfe0c:

[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

Note: See TracTickets for help on using tickets.
Back to Top