Opened 3 years ago
Closed 3 years ago
#32972 closed Bug (invalid)
Django ORM raw query not playing nice with Geometric Point objects
Reported by: | Donovan | Owned by: | nobody |
---|---|---|---|
Component: | GIS | Version: | 3.2 |
Severity: | Normal | Keywords: | ORM raw query geometric location point |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
When using <Object>.objects.all() the behavior works as intended and I am able to get the Geometric Point object with the latitude and longitude correct.
When using <Object>.objects.raw() the Point object has incorrect latitude and longitude -- it has scientific notation and completely different numbers.
Attachments (2)
Change History (3)
by , 3 years ago
Attachment: | incorrect Point objects.png added |
---|
by , 3 years ago
Attachment: | expected location after serializing.png added |
---|
What the the Point object should have for latitude and longitude
comment:1 by , 3 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
Using .raw()
is a last resort. Django takes a raw SQL query, executes it, and returns results (as documented), it will not automatically add any data conversion to columns. Geometry columns returned by the ORM are wrapped with db-specific functions, e.g. %s::bytea
on PostgreSQL or SDO_UTIL.TO_WKBGEOMETRY(%s)
on Oracle.
If you're having trouble understanding how Django works, see TicketClosingReasons/UseSupportChannels for ways to get help.
Showing what the point objects look like with a <object>.objects.raw() query look like when doing a print(vars(object))