Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#16537 closed Bug (fixed)

layermapping spatial ref check not checking against alternate DB

Reported by: shifflett.shane@… Owned by: jbronn
Component: GIS Version: 1.3
Severity: Release blocker Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


django/contrib/gis/utils/ uses alternate database to save geometries however when checking the SRID against the SPATIAL REF table it does not check against an alternate database if the user specifies one. For a user to experience this error they must have two databases and the default database cannot store shape data.

issue occurs in django/contrib/gis/utils/ line 432

OLD CODE (SRID lookup will fail if user has an alternate database storing shape data):
target_srs = SpatialRefSys.objects.get(srid=self.geo_field.srid).srs

PROPOSED FIX (SRID lookup succeeds and functions similar to SAVE function):
target_srs = SpatialRefSys.objects.using(self.using).get(srid=self.geo_field.srid).srs

Attachments (2)

16537.diff (1.4 KB) - added by Aymeric Augustin 8 years ago.
16537.2.diff (2.6 KB) - added by jbronn 8 years ago.

Download all attachments as: .zip

Change History (8)

comment:1 Changed 8 years ago by Aymeric Augustin

Easy pickings: unset
Needs tests: set
Triage Stage: UnreviewedAccepted

This line dates back to the merge of multi-db at r11952, but it was changed because of the general refactoring of django.contrib.gis that happened in that commit, not specifically to add multi-db support.

A similar problem was fixed in django/contrib/gis/db/models/ at r12258.

I think the problem also happens in django/contrib/gis/utils/ I'm attaching a new patch that also fixes this. This patch is based on code inspection and isn't tested.

Changed 8 years ago by Aymeric Augustin

Attachment: 16537.diff added

comment:2 Changed 8 years ago by Aymeric Augustin

#16556 was a duplicate.

comment:3 Changed 8 years ago by Aymeric Augustin

#16620 was a duplicate.

comment:4 Changed 8 years ago by jbronn

milestone: 1.4
Needs tests: unset
Owner: changed from nobody to jbronn
Severity: NormalRelease blocker
Status: newassigned

Changed 8 years ago by jbronn

Attachment: 16537.2.diff added

comment:5 Changed 8 years ago by jbronn

Resolution: fixed
Status: assignedclosed

In [16779]:

Fixed #16537 -- Fixed multi-db issues with GeoDjango utilities. Thanks, Shane Shifflett for the bug report and aaugustin for the initial patch.

comment:6 Changed 8 years ago by Jacob

milestone: 1.4

Milestone 1.4 deleted

Note: See TracTickets for help on using tickets.
Back to Top