Document the effect of setting BaseSpatialField.srid to -1
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
(7)
| Owner: |
set to Yassin Bahri
|
| Status: |
new → assigned
|
| Triage Stage: |
Unreviewed → Accepted
|
| Patch needs improvement: |
set
|
| Patch needs improvement: |
unset
|
| Triage Stage: |
Accepted → Ready for checkin
|
| Resolution: |
→ fixed
|
| Status: |
assigned → closed
|
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.