Code

Opened 6 years ago

Closed 4 years ago

Last modified 4 years ago

#8904 closed (fixed)

GeoDjango should raise a more informative exception when doing distance queries on MySQL

Reported by: robstar Owned by: jbronn
Component: GIS Version: 1.0
Severity: Keywords:
Cc: Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description (last modified by jbronn)

A better error should be reported for when a distance lookup is attempted with mysql:

>>> qs = Building.gobjects.filter(geo_loc__distance_lte=(x, D(km=7)))
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/root/django-svn/Django-1.0-beta_2/django/db/models/manager.py", line 90, in filter
    return self.get_query_set().filter(*args, **kwargs)
  File "/root/django-svn/Django-1.0-beta_2/django/db/models/query.py", line 481, in filter
    return self._filter_or_exclude(False, *args, **kwargs)
  File "/root/django-svn/Django-1.0-beta_2/django/db/models/query.py", line 499, in _filter_or_exclude
    clone.query.add_q(Q(*args, **kwargs))
  File "/root/django-svn/Django-1.0-beta_2/django/db/models/sql/query.py", line 1189, in add_q
    can_reuse=used_aliases)
  File "/root/django-svn/Django-1.0-beta_2/django/db/models/sql/query.py", line 1061, in add_filter
    parts, opts, alias, True, allow_many, can_reuse=can_reuse)
  File "/root/django-svn/Django-1.0-beta_2/django/db/models/sql/query.py", line 1377, in setup_joins
    raise FieldError("Join on field %r not permitted." % name)
FieldError: Join on field 'geo_loc' not permitted.

Attachments (0)

Change History (5)

comment:1 Changed 6 years ago by jbronn

  • Description modified (diff)
  • Needs documentation unset
  • Needs tests unset
  • Owner changed from nobody to jbronn
  • Patch needs improvement unset
  • Summary changed from geodjango should return more informative error for mysql non-support to geodjango should return more informative error for lack of MySQL distance queries
  • Version changed from 1.0-beta-1 to 1.0

Yes, a better error needs to be raised.

comment:2 Changed 6 years ago by jbronn

  • Summary changed from geodjango should return more informative error for lack of MySQL distance queries to GeoDjango should raise a more informative exception when doing distance queries on MySQL
  • Triage Stage changed from Unreviewed to Design decision needed

comment:3 Changed 6 years ago by jbronn

I haven't forgotten about this ticket, I'm going to do this when I change other things across the spatial backends.

comment:4 Changed 4 years ago by jbronn

  • Resolution set to fixed
  • Status changed from new to closed

(In [12887]) Fixed #8904 -- Improved error message when spatial lookup is not available, and changed exception to ValueError to prevent swallowing of error on queryset evaluation.

comment:5 Changed 4 years ago by jbronn

No need to backport to 1.1.X -- due to the way queries were constructed pre multi-db, the error would never be propagated up. Regardless, the message was been improved anyways for 1.1 users, who would see:

FieldError: Join on field 'geom' not permitted. Did you misspell 'distance_lte' for the lookup type?

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.