Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#16556 closed Bug (duplicate)

django.contrib.gis.utils.srs fails to preserve database when creating SpatialRefSys querysets

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

Description (last modified by jbronn)

django.contrib.gis.utils.srs fails to preserve database when creating SpatialRefSys querysets

Currently, the code (line ~70 or so) reads like this:

    # Creating the spatial_ref_sys model.
    try:
        # Try getting via SRID only, because using all kwargs may
        # differ from exact wkt/proj in database.
        sr = SpatialRefSys.objects.get(srid=srs.srid)
    except SpatialRefSys.DoesNotExist:
        sr = SpatialRefSys.objects.create(**kwargs)

It should read like this:

    # Creating the spatial_ref_sys model.
    try:
        # Try getting via SRID only, because using all kwargs may
        # differ from exact wkt/proj in database.
        sr = SpatialRefSys.objects.using(database).get(srid=srs.srid)
    except SpatialRefSys.DoesNotExist:
        sr = SpatialRefSys.objects.using(database).create(**kwargs)

Otherwise support for multiple backends is sort of broken.

Attachments (1)

srs.patch (641 bytes) - added by chander.ganesan@… 4 years ago.
Patch to correct this bug ..

Download all attachments as: .zip

Change History (5)

comment:1 Changed 4 years ago by anonymous

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Ugh. Basically, the '.using()' method needs to be used when creating the SpatialRefSys query set. sorry for the poor formatting.

comment:2 Changed 4 years ago by jbronn

  • Description modified (diff)
  • milestone set to 1.4
  • Owner changed from chander.ganesan@… to jbronn
  • Status changed from new to assigned
  • Triage Stage changed from Unreviewed to Accepted

Changed 4 years ago by chander.ganesan@…

Patch to correct this bug ..

comment:3 Changed 4 years ago by aaugustin

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

This is a duplicate of #16537. Please search before opening a new ticket — here, it's completely trivial to find the duplicate: https://code.djangoproject.com/search?q=SpatialRefSys&noquickjump=1&ticket=on

comment:4 Changed 4 years ago by jacob

  • milestone 1.4 deleted

Milestone 1.4 deleted

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