Opened 8 years ago

Last modified 2 years ago

#27464 new Cleanup/optimization

SRID should be stored in DB on MySQL backend

Reported by: Sergey Fedoseev Owned by:
Component: GIS Version: dev
Severity: Normal Keywords: mysql
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

MySQL does not support SRID constraints on columns and SRID is stored together with the geometry itself.
Django always saves geometries with SRID 0 on MySQL backend.
This leads to the problem I encountered while working on #26967: AsGeoJSON function never returns the coordinate system because SRID is always 0.
Probably such Django behavior will lead to more problems in the future (e.g. if/when MySQL will get ST_Transform function).

Saving SRID will be breaking change because the old geometries in DB will have SRID 0, Django will provide geometries with SRID and MySQL 5.7+ raises error if geometry arguments have different SRIDs. To make it work MySQL users will have to set SRIDs for geometries in DB (call save() for every object of every GIS model).

Change History (4)

comment:1 by Sergey Fedoseev, 8 years ago

Owner: changed from nobody to Sergey Fedoseev
Status: newassigned

comment:2 by Tim Graham, 8 years ago

Triage Stage: UnreviewedAccepted

I'm not a GIS user, but based on the description, it seems like it could be a large backwards-incompatibility. It might be nice to raise it on the geodjango mailing list to make sure there's consensus about it.

comment:3 by Sergey Fedoseev, 5 years ago

MySQL 8 allows to create GEOMETRY columns with explicitly set SRID.: https://dev.mysql.com/doc/refman/8.0/en/spatial-type-overview.html.

comment:4 by Sergey Fedoseev, 2 years ago

Owner: Sergey Fedoseev removed
Status: assignednew
Note: See TracTickets for help on using tickets.
Back to Top