Opened 15 years ago

Closed 15 years ago

Last modified 15 years ago

#12334 closed (invalid)

GeoQuerySet creates invalid SQL on calls to `__nonzero__` or `__len__`

Reported by: wardi Owned by: nobody
Component: GIS Version: 1.1
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

from django.contrib.gis.db import models
from django.contrib.gis.geos import Point

class Location(models.Model):
    point = models.PointField()

bool(Location.objects.filter(point=Point(1,0)))

causes an exception in the regular django db layer (not the gis one), it looks like the implementation of __nonzero__ and __len__ in QuerySet are not properly overridden by GeoQuerySet.

Change History (3)

comment:1 by wardi, 15 years ago

Component: UncategorizedGIS

comment:2 by jbronn, 15 years ago

Resolution: invalid
Status: newclosed

You forgot:

    objects = models.GeoManager()

See also the GeoManager documentation.

comment:3 by wardi, 15 years ago

Thanks jbronn!

The error is a little misleading, though, and the result of user error probably shouldn't be generating invalid SQL.

Ian

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