#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.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/057.3d8bb36f7c4a82232734ebebef01ba3a%40djangoproject.com.

Reply via email to