#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 <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.f9a2166eb112044ab936b1dae1befca4%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to