{{{#!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.
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>
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>
* 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>
* cc: felixxm (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/29054#comment:4>
* owner: nobody => felixxm
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/29054#comment:5>
* has_patch: 0 => 1
Comment:
[https://github.com/django/django/pull/9620 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/29054#comment:6>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/29054#comment:7>
* 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>
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>