Opened 5 years ago

Closed 5 years ago

Last modified 5 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 aaugustin 5 years ago.
16537.2.diff (2.6 KB) - added by jbronn 5 years ago.

Download all attachments as: .zip

Change History (8)

comment:1 Changed 5 years ago by aaugustin

  • Easy pickings unset
  • Needs documentation unset
  • Needs tests set
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

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 5 years ago by aaugustin

comment:2 Changed 5 years ago by aaugustin

#16556 was a duplicate.

comment:3 Changed 5 years ago by aaugustin

#16620 was a duplicate.

comment:4 Changed 5 years ago by jbronn

  • milestone set to 1.4
  • Needs tests unset
  • Owner changed from nobody to jbronn
  • Severity changed from Normal to Release blocker
  • Status changed from new to assigned

Changed 5 years ago by jbronn

comment:5 Changed 5 years ago by jbronn

  • Resolution set to fixed
  • Status changed from assigned to closed

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 5 years ago by jacob

  • milestone 1.4 deleted

Milestone 1.4 deleted

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