Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The sqldiff command doesn't recognize GeoDjango and JSON fields #1010

Closed
imagescape opened this issue Feb 6, 2017 · 6 comments · Fixed by #1191
Closed

The sqldiff command doesn't recognize GeoDjango and JSON fields #1010

imagescape opened this issue Feb 6, 2017 · 6 comments · Fixed by #1191

Comments

@imagescape
Copy link

The sqldiff is a great tool. However, I'm noticing that it does not recognize less common fields, such as PointFields from GeoDjango and JSON fields from the django-jsonfield project. Even if I run the alter statements that sqldiff suggests, sqldiff still reports difference in the output.

The sqldiff command doesn't seem to recognize geography columns from GeoDjango:

Code Sample:

from django.contrib.gis.db import models as geomodels
class Location(models.Model):
    ...
    point = geomodels.PointField(editable=False, geography=True, null=True)

Sqldiff output:

-- Application: eventcalendar
-- Model: Location
-- Comment: Unknown database type for field 'point' (130253)
ALTER TABLE "eventcalendar_location"
	ALTER "point" TYPE geography(POINT,4326);

The sqldiff command doesn't seem to recognize geometry columns from GeoDjango:

Code Sample:

from django.contrib.gis.db import models as geomodels
class Office(models.Model):
    ...
    point = geomodels.PointField(editable=False)

Sqldiff output:

-- Application: physicians
-- Model: Office
-- Comment: Unknown database type for field 'point' (129699)
ALTER TABLE "physicians_office"
ALTER "point" TYPE geometry(POINT,4326);
COMMIT;

The sqldiff command doesn't seem to recognize jsonfields (from django-jsonfield). I haven't tried with the newer built-in jsonfields yet, so maybe it will work with that?

Code Sample:
https://github.com/ImaginaryLandscape/django_site_config/blob/master/site_config/backends/model_backend/models.py#L110

Sqldiff output:

-- Application: site_config
-- Model: WebsiteApplication
-- Comment: Unknown database type for field 'options' (114)
ALTER TABLE "site_config_websiteapplication"
	ALTER "options" TYPE text;
@trbs
Copy link
Member

trbs commented Feb 6, 2017

Regretfully I did not have the time in the last year to properly continue to develop sqldiff :(

Probably recent versions of Django ORM also have better introspection tools for sqldiff to do the comparisons. I will leave this open and hopefully I or somebody else has time to continue making sqldiff better and more compatible with fields.

@xavfernandez
Copy link
Contributor

xavfernandez commented Apr 5, 2018

The part about JSONField is not fixed though.

@t-book
Copy link

t-book commented Nov 23, 2018

Any updates on JSONField support?

@trbs
Copy link
Member

trbs commented Nov 23, 2018

Can we open a new issue for this ?

Think for both JSONField's the type is TEXT is the right answer is it not ?

@jrd
Copy link
Contributor

jrd commented Nov 26, 2018

Some database (postgresql) can store json in a JSON column type

@t-book
Copy link

t-book commented Nov 26, 2018

exactly. The problem happens when some app uses the JSONField type of postgresql.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants