[Django] #29054: Unhashable type Point bug with multiple annotations

26 views
Skip to first unread message

Django

unread,
Jan 23, 2018, 8:42:44 PM1/23/18
to django-...@googlegroups.com
#29054: Unhashable type Point bug with multiple annotations
------------------------------------------+------------------------
Reporter: Lachlan Cannon | Owner: nobody
Type: Uncategorized | Status: new
Component: GIS | Version: 2.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------+------------------------
Simplified example to reproduce, with these models:

{{{#!python
class State(models.Model):
name = models.CharField(max_length=100)

class Location(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):

{{{#!python
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':

{{{#!python
State.objects.annotate(distance=Distance('locality__location',
self.locality.location)).annotate(count=Count('locality'))
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29054>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 23, 2018, 8:43:29 PM1/23/18
to django-...@googlegroups.com
#29054: Unhashable type Point bug with multiple annotations
--------------------------------+--------------------------------------

Reporter: Lachlan Cannon | Owner: nobody
Type: Uncategorized | Status: new
Component: GIS | Version: 2.0
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------+--------------------------------------
Description changed by Lachlan Cannon:

Old description:

> Simplified example to reproduce, with these models:
>
> {{{#!python
> class State(models.Model):
> name = models.CharField(max_length=100)
>
> class Location(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):
>
> {{{#!python
> 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':
>
> {{{#!python
> State.objects.annotate(distance=Distance('locality__location',
> self.locality.location)).annotate(count=Count('locality'))
> }}}

New description:

Simplified example to reproduce, with these models:

{{{#!python
class State(models.Model):
name = models.CharField(max_length=100)

class Localitymodels.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):

{{{#!python
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':

{{{#!python
State.objects.annotate(distance=Distance('locality__location',
self.locality.location)).annotate(count=Count('locality'))
}}}

--

--
Ticket URL: <https://code.djangoproject.com/ticket/29054#comment:1>

Django

unread,
Jan 23, 2018, 8:43:45 PM1/23/18
to django-...@googlegroups.com
#29054: Unhashable type Point bug with multiple annotations
--------------------------------+--------------------------------------

Reporter: Lachlan Cannon | Owner: nobody
Type: Uncategorized | Status: new
Component: GIS | Version: 2.0
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------+--------------------------------------
Description changed by Lachlan Cannon:

Old description:

> Simplified example to reproduce, with these models:


>
> {{{#!python
> class State(models.Model):
> name = models.CharField(max_length=100)
>

> class Localitymodels.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):
>
> {{{#!python
> 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':
>
> {{{#!python
> State.objects.annotate(distance=Distance('locality__location',
> self.locality.location)).annotate(count=Count('locality'))
> }}}

New description:

Simplified example to reproduce, with these models:

{{{#!python
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):

{{{#!python
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':

{{{#!python
State.objects.annotate(distance=Distance('locality__location',
self.locality.location)).annotate(count=Count('locality'))
}}}

--

--
Ticket URL: <https://code.djangoproject.com/ticket/29054#comment:2>

Django

unread,
Jan 24, 2018, 10:01:22 AM1/24/18
to django-...@googlegroups.com
#29054: QuerySet with multiple annotations crashes with "unhashable type: 'Point'"
---------------------------------+------------------------------------

Reporter: Lachlan Cannon | Owner: nobody
Type: Bug | Status: new
Component: GIS | Version: 2.0
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by Tim Graham):

* cc: Ian Foote (added)
* stage: Unreviewed => Accepted
* type: Uncategorized => Bug
* severity: Normal => Release blocker


Comment:

Bisected to 19b2dfd1bfe7fd716dd3d8bfa5f972070d83b42f.

--
Ticket URL: <https://code.djangoproject.com/ticket/29054#comment:3>

Django

unread,
Jan 24, 2018, 12:12:57 PM1/24/18
to django-...@googlegroups.com
#29054: QuerySet with multiple annotations crashes with "unhashable type: 'Point'"
---------------------------------+------------------------------------
Reporter: Lachlan Cannon | Owner: nobody
Type: Bug | Status: new
Component: GIS | Version: 2.0

Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by felixxm):

* cc: felixxm (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/29054#comment:4>

Django

unread,
Jan 25, 2018, 2:35:12 PM1/25/18
to django-...@googlegroups.com
#29054: QuerySet with multiple annotations crashes with "unhashable type: 'Point'"
---------------------------------+------------------------------------
Reporter: Lachlan Cannon | Owner: felixxm
Type: Bug | Status: assigned
Component: GIS | Version: 2.0

Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by felixxm):

* owner: nobody => felixxm
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/29054#comment:5>

Django

unread,
Jan 25, 2018, 4:10:51 PM1/25/18
to django-...@googlegroups.com
#29054: QuerySet with multiple annotations crashes with "unhashable type: 'Point'"
---------------------------------+------------------------------------
Reporter: Lachlan Cannon | Owner: felixxm
Type: Bug | Status: assigned
Component: GIS | Version: 2.0

Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by felixxm):

* has_patch: 0 => 1


Comment:

[https://github.com/django/django/pull/9620 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/29054#comment:6>

Django

unread,
Jan 26, 2018, 2:17:29 PM1/26/18
to django-...@googlegroups.com
#29054: QuerySet with multiple annotations crashes with "unhashable type: 'Point'"
-------------------------------------+-------------------------------------

Reporter: Lachlan Cannon | Owner: felixxm
Type: Bug | Status: assigned
Component: GIS | Version: 2.0
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/29054#comment:7>

Django

unread,
Jan 27, 2018, 5:12:51 AM1/27/18
to django-...@googlegroups.com
#29054: QuerySet with multiple annotations crashes with "unhashable type: 'Point'"
-------------------------------------+-------------------------------------
Reporter: Lachlan Cannon | Owner: felixxm
Type: Bug | Status: closed
Component: GIS | Version: 2.0
Severity: Release blocker | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by GitHub <noreply@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"b002a032f90b8cd228cfcee6c88cd238a8191cc0" b002a032]:
{{{
#!CommitTicketReference repository=""
revision="b002a032f90b8cd228cfcee6c88cd238a8191cc0"
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.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29054#comment:8>

Django

unread,
Jan 27, 2018, 5:16:18 AM1/27/18
to django-...@googlegroups.com
#29054: QuerySet with multiple annotations crashes with "unhashable type: 'Point'"
-------------------------------------+-------------------------------------
Reporter: Lachlan Cannon | Owner: felixxm
Type: Bug | Status: closed
Component: GIS | Version: 2.0

Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"42622b8934d46a8f07d1f89b66edbcffa98f3f4a" 42622b89]:
{{{
#!CommitTicketReference repository=""
revision="42622b8934d46a8f07d1f89b66edbcffa98f3f4a"
[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
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29054#comment:9>

Reply all
Reply to author
Forward
0 new messages