Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#29054 closed Bug (fixed)

QuerySet with multiple annotations crashes with "unhashable type: 'Point'"

Reported by: Lachlan Cannon Owned by: Mariusz Felisiak
Component: GIS Version: 2.0
Severity: Release blocker Keywords:
Cc: Ian Foote, Mariusz Felisiak Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Lachlan Cannon)

Simplified example to reproduce, with these models:

class State(models.Model):
    name = models.CharField(max_length=100)

class Locality(models.Model):
    name = models.CharField(max_length=100)
    location = models.PointField(geography=True)
    state = models.ForeignKey(State, on_delete=models.CASCADE)

Running the following code works fine in 2.0 (assuming you have a few models set up):

State.objects.annotate(distance=Distance('locality__location', Locality.objects.first().location))

But this code works in 1.11, and fails in 2.0.1 with TypeError: unhashable type: 'Point':

State.objects.annotate(distance=Distance('locality__location', self.locality.location)).annotate(count=Count('locality'))

Change History (9)

comment:1 by Lachlan Cannon, 6 years ago

Description: modified (diff)

comment:2 by Lachlan Cannon, 6 years ago

Description: modified (diff)

comment:3 by Tim Graham, 6 years ago

Cc: Ian Foote added
Severity: NormalRelease blocker
Summary: Unhashable type Point bug with multiple annotationsQuerySet with multiple annotations crashes with "unhashable type: 'Point'"
Triage Stage: UnreviewedAccepted
Type: UncategorizedBug

comment:4 by Mariusz Felisiak, 6 years ago

Cc: Mariusz Felisiak added

comment:5 by Mariusz Felisiak, 6 years ago

Owner: changed from nobody to Mariusz Felisiak
Status: newassigned

comment:6 by Mariusz Felisiak, 6 years ago

Has patch: set

comment:7 by Tim Graham, 6 years ago

Triage Stage: AcceptedReady for checkin

comment:8 by GitHub <noreply@…>, 6 years ago

Resolution: fixed
Status: assignedclosed

In b002a032:

Fixed #29054 -- Fixed a regression where a queryset that annotates with geometry objects crashes.

Made GEOSGeometryBase hashable.
Regression in 19b2dfd1bfe7fd716dd3d8bfa5f972070d83b42f.

Thanks Tim Graham for the review.

comment:9 by Mariusz Felisiak <felisiak.mariusz@…>, 6 years ago

In 42622b89:

[2.0.x] Fixed #29054 -- Fixed a regression where a queryset that annotates with geometry objects crashes.

Made GEOSGeometryBase hashable.
Regression in 19b2dfd1bfe7fd716dd3d8bfa5f972070d83b42f.

Thanks Tim Graham for the review.
Backport of b002a032f90b8cd228cfcee6c88cd238a8191cc0 from master

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