Opened 15 years ago
Closed 15 years ago
#269 closed defect (fixed)
Geography->Geometry cast should be explicit
Reported by: | mcayland | Owned by: | pramsey |
---|---|---|---|
Priority: | medium | Milestone: | PostGIS 1.5.0 |
Component: | postgis | Version: | |
Keywords: | Cc: |
Description (last modified by )
Changed subject:
We really shouldn't be allowing people to use functions designated for geometry with geography data type without forcing them to explicitly cast to geometry.
This is bad:
trunk=# explain analyze select count(*) from cities where the_geog && ST_SetSRID(ST_GeographyFromText('POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))'), 4326);
ERROR: operator is not unique: geography && geometry LINE 1: ...nalyze select count(*) from cities where the_geog && ST_SetS...
Change History (6)
comment:1 by , 15 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:2 by , 15 years ago
Oh - I totally agree that geometry && geography is a no-no, but the error message being returned is effectively a developer's error saying "Don't do that". Abusing the implicit cast system in this way to enable things to get this far is just plain wrong, and will cause confusion to users as to exactly which functions have been tested in a geography context and which haven't. With the cast removed, I get the following message which is a lot more sensible:
trunk=# explain analyze select count(*) from cities where the_geog && ST_SetSRID(ST_GeographyFromText('POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))'), 4326);
ERROR: function st_setsrid(geography, integer) does not exist
I'd like to propose that we remove the implict cast and replace it with an explicit cast instead. Then if users want to try functions that haven't been tested with geography, then at least they will be made aware they are trying something non-standard and can face the relevant consequences.
comment:3 by , 15 years ago
Description: | modified (diff) |
---|---|
Resolution: | invalid |
Status: | closed → reopened |
Summary: | Geometry -> Geography autocast causes && operator query to fail → Geometry -> Geography autocast should be explicit |
Ah okay that's what you are complaining about. I'm in full agreement with you on this one then. I'm going to change the subject line to be clearer and reopen the ticket.
comment:4 by , 15 years ago
Summary: | Geometry -> Geography autocast should be explicit → Geography->Geometry cast should be explicit |
---|
comment:6 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
I tried it I like it. committed at r4656
Mark, I consider this bug invalid and not a bug. I don't personally see this as an issue because how would it know -- If people exercise this it will be
geography && unknown
geometry && unknown
In which case the operation is not ambiguous. In your case you are clearly doing a
geometry && geography which is a big no no in my book. And you should be slapped on the wrist for even attempting such a silly thing :)
for example the below works perfectly fine.