Opened 65 minutes ago
Last modified 41 minutes ago
#37321 assigned Bug
Document the effect of setting BaseSpatialField.srid to -1
| Reported by: | Jacob Walls | Owned by: | Yassin Bahri |
|---|---|---|---|
| Component: | Documentation | Version: | 6.1 |
| 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
For spatial model fields, setting a -1 srid has a special meaning, and it's tested:
class MinusOneSRID(models.Model): geom = models.PointField(srid=-1) # Minus one SRID.
However, the documentation says nothing about this special meaning. It was added in #7579.
I'm suggesting we should document its effect (no SRID transform will be attempted, assigned geometries/rasters will lose any explicit srid). This would have been helpful when responding to a forum post where a user tried to set srid=None, which doesn't work.
Change History (2)
comment:1 by , 41 minutes ago
comment:2 by , 41 minutes ago
| Owner: | set to |
|---|---|
| Status: | new → assigned |
| Triage Stage: | Unreviewed → Accepted |
Note:
See TracTickets
for help on using tickets.
I reviewed the implementation, the existing documentation, and the behavior introduced in #7579. This is a valid documentation bug, and I was unable to find a duplicate ticket.
The current
BaseSpatialField.sriddocumentation does not explain the intentional special behavior ofsrid=-1.When Django prepares a geometry or raster for a database operation,
BaseSpatialField.get_prep_value()sets its SRID to-1. This prevents an automatic transformation to the field's coordinate system, but it also means that the value's original explicit SRID is not preserved.I am marking this ticket as Accepted, assigning it to myself, and will update the
BaseSpatialField.sriddocumentation to explain this behavior clearly.The documentation will clarify that:
srid=-1disables automatic SRID transformation.-1when prepared for database operations.