Opened 13 years ago

Closed 13 years ago

Last modified 13 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

Description

django/contrib/gis/utils/layermapping.py 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/layermapping.py 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 13 years ago.
16537.2.diff (2.6 KB ) - added by jbronn 13 years ago.

Download all attachments as: .zip

Change History (8)

comment:1 by Aymeric Augustin, 13 years ago

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/fields.py at r12258.

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

by Aymeric Augustin, 13 years ago

Attachment: 16537.diff added

comment:2 by Aymeric Augustin, 13 years ago

#16556 was a duplicate.

comment:3 by Aymeric Augustin, 13 years ago

#16620 was a duplicate.

comment:4 by jbronn, 13 years ago

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

by jbronn, 13 years ago

Attachment: 16537.2.diff added

comment:5 by jbronn, 13 years ago

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 by Jacob, 13 years ago

milestone: 1.4

Milestone 1.4 deleted

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