Opened 8 years ago

Last modified 3 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
Pull Requests:How to create a pull request

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

According to the ticket's flags, the next step(s) to move this issue forward are:

  • To provide a patch by sending a pull request. Claim the ticket when you start working so that someone else doesn't duplicate effort. Before sending a pull request, review your work against the patch review checklist. Check the "Has patch" flag on the ticket after sending a pull request and include a link to the pull request in the ticket comment when making that update. The usual format is: [https://github.com/django/django/pull/#### PR].

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, 3 years ago

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