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)

incorrect Point objects.png (30.3 KB ) - added by Donovan 3 years ago.
Showing what the point objects look like with a <object>.objects.raw() query look like when doing a print(vars(object))
expected location after serializing.png (3.5 KB ) - added by Donovan 3 years ago.
What the the Point object should have for latitude and longitude

Download all attachments as: .zip

Change History (3)

by Donovan, 3 years ago

Attachment: incorrect Point objects.png added

Showing what the point objects look like with a <object>.objects.raw() query look like when doing a print(vars(object))

by Donovan, 3 years ago

What the the Point object should have for latitude and longitude

comment:1 by Mariusz Felisiak, 3 years ago

Resolution: invalid
Status: newclosed

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.

Note: See TracTickets for help on using tickets.
Back to Top