Opened 12 years ago

Closed 8 years ago

#18565 closed Bug (wontfix)

Point object doesn't work in queyset.extra params argument

Reported by: jbzdak@… Owned by: nobody
Component: GIS Version: 1.4
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

While using GIS objects in queryset lookups (like distance etc) works OK, these objects don't work when passed as params argument in queryset.extra function.

queryset = queryset.extra(where=['mm_hitchhiker_search("move_move"."path", %s, %s)'], params=[from_waypoint.point, to_waypoint.point])

Change History (4)

comment:1 by anonymous, 12 years ago

Type: UncategorizedBug

Oh fuck. I didn't provide explanation.

Following snippet:

queryset = queryset.extra(where=['mm_hitchhiker_search("move_move"."path", %s, %s)'], params=[from_waypoint.point, to_waypoint.point])

produces error:

Internal Server Error: /search/ajax/hitchhiker
Traceback (most recent call last):
 (...)
  File "/home/jb/programs/meetmove/django/template/defaulttags.py", line 145, in render
    len_values = len(values)
  File "/home/jb/programs/meetmove/django/db/models/query.py", line 85, in __len__
    self._result_cache = list(self.iterator())
  File "/home/jb/programs/meetmove/django/db/models/query.py", line 291, in iterator
    for row in compiler.results_iter():
  File "/home/jb/programs/meetmove/django/db/models/sql/compiler.py", line 763, in results_iter
    for rows in self.execute_sql(MULTI):
  File "/home/jb/programs/meetmove/django/db/models/sql/compiler.py", line 818, in execute_sql
    cursor.execute(sql, params)
  File "/home/jb/programs/meetmove/django/db/backends/util.py", line 40, in execute
    return self.cursor.execute(sql, params)
  File "/home/jb/programs/meetmove/django/db/backends/postgresql_psycopg2/base.py", line 52, in execute
    return self.cursor.execute(query, args)
DatabaseError: can't adapt type 'Point'
[04/Jul/2012 07:14:56] "POST /search/ajax/hitchhiker HTTP/1.1" 500 15796
Version 0, edited 12 years ago by anonymous (next)

comment:2 by Claude Paroz, 12 years ago

Triage Stage: UnreviewedAccepted

Basically, a standard WhereNode go through: as_sql() -> make_atom() (from contrib.gis) -> lvalue.process() -> field.get_db_prep_lookup() -> connection.ops.Adapter(point)

An ExtraWhere is much more simple and just inject the params in the sql string.

I suspect this will end up in a documentation fix to explain the limitation (or tell to manually call the Adapter() method?). We need an ORM guru to confirm.

comment:3 by Ramiro Morales, 11 years ago

Summary: Point object doesn't work in quqeyset.extra params argumentPoint object doesn't work in queyset.extra params argument

comment:4 by Tim Graham, 8 years ago

Resolution: wontfix
Status: newclosed

Closing since we aren't fixing issues with QuerySet.extra(). It'll be deprecated once obsoleted.

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