Opened 13 years ago
Closed 13 years ago
#16620 closed Bug (duplicate)
django.contrib.gis.utils.srs.add_srs_entry doesn't use the database parameter
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | GIS | Version: | 1.3 |
Severity: | Normal | Keywords: | |
Cc: | adamfast | Triage Stage: | Accepted |
Has patch: | no | Needs documentation: | no |
Needs tests: | yes | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
When using add_srs_entry
like add_srs_entry(900913, database="gis")
, it still goes to default database. Correct should be
# 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)
Change History (2)
comment:1 by , 13 years ago
Cc: | added |
---|---|
Needs tests: | set |
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 13 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
More background: user has a non-spatial primary database (MySQL) and is using spatialite as a secondary database (named gis) for GIS data. When attempting to run add_srs_entry() GeoDjango is attempting to create the record on his (default) MySQL db which errors since there is no SRS capability in that backend.
Confirmed as an issue. In this code SpatialRefSys is pulled from connection.ops.spatial_ref_sys() (connection being the proper connection for the database alias passed in) but the implementation in the backend is to simply import and return the model from the backend and not pass on which database alias is to be used so running .get or .create uses the default DB and not the one passed in. A using() here is probably the right solution.