Opened 23 months ago

Closed 23 months ago

Last modified 23 months ago

#29054 closed Bug (fixed)

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

Reported by: Lachlan Cannon Owned by: felixxm
Component: GIS Version: 2.0
Severity: Release blocker Keywords:
Cc: Ian Foote, felixxm 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 Changed 23 months ago by Lachlan Cannon

Description: modified (diff)

comment:2 Changed 23 months ago by Lachlan Cannon

Description: modified (diff)

comment:3 Changed 23 months ago by Tim Graham

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 Changed 23 months ago by felixxm

Cc: felixxm added

comment:5 Changed 23 months ago by felixxm

Owner: changed from nobody to felixxm
Status: newassigned

comment:6 Changed 23 months ago by felixxm

Has patch: set

comment:7 Changed 23 months ago by Tim Graham

Triage Stage: AcceptedReady for checkin

comment:8 Changed 23 months ago by GitHub <noreply@…>

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 Changed 23 months ago by Mariusz Felisiak <felisiak.mariusz@…>

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