#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 , 5 years ago
| Cc: | added |
|---|---|
| Component: | Core (System checks) → Database layer (models, ORM) |
| Owner: | changed from to |
| Severity: | Normal → Release blocker |
| Status: | new → assigned |
| Summary: | SQLite3 bad filepath raising as JSON extension error → SQLite3 bad filepath raising as JSON extension error. |
| Triage Stage: | Unreviewed → Accepted |
comment:3 by , 5 years ago
| Triage Stage: | Accepted → Ready for checkin |
|---|
Thanks for the report.
Regression in 6789ded0a6ab797f0dcdfa6ad5d1cfa46e23abcd.
Reproduced at c70cd2a926ffab47f6613e83e0c8828eb6c2c064.