raphaelm / django-jsonfallback

Use PostgreSQL's and MySQL's JSONField, but fall back to a TextField implementation on other databases
Apache License 2.0
24 stars 4 forks source link

Does not work correcly on Postgresql with Postgis extensions #3

Open jrd opened 4 years ago

jrd commented 4 years ago

When using a Postgresql with Postgis extensions, the driver used is a wrapper around the postgres one to handle postgis extensions.

Unfortunately, the driver name does not contains '.postgresql' in the engine name. The engine string is django.contrib.gis.db.backends.postgis

So maybe change some tests like

if '.postgresql' in connection.settings_dict['ENGINE']:

To

if any((
    '.postgresql' in connection.settings_dict['ENGINE'],
    '.postgis' in connection.settings_dict['ENGINE']
)):

Or just shorten the search:

if '.postg' in connection.settings_dict['ENGINE']:
raphaelm commented 4 years ago

I'd be happy to accept a pull request, although keep in mind that we'll probably discontinue this library as soon as django 3.1 has been released and we've found a good migration path:

https://docs.djangoproject.com/en/dev/releases/3.1/#jsonfield-for-all-supported-database-backends