Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#27314 closed Bug (invalid)

PointField can't be used in get_or_create

Reported by: kemar Owned by: nobody
Component: GIS Version: 1.10
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

  • Django 1.10.2
  • PostgreSQL 9.4.9
  • PostGIS 2.2.2

With this model:

from django.contrib.gis.db import models as gis_models
from django.db import models as django_models

class MyModel(django_models.Model):
    coords = gis_models.PointField(geography=True)

Try this:

>>> i = MyModel.objects.all()[0]
>>> type(i.coords)
>>> django.contrib.gis.geos.point.Point
>>> MyModel.objects.get_or_create(coords=i.coords)

ValueError: PostGIS geography does not support the "~=" function/operator.

But `~=` is a valid operator.

Looks like a bug to me.

Attachments (1)

traceback.py (4.6 KB ) - added by kemar 8 years ago.
Traceback

Download all attachments as: .zip

Change History (5)

by kemar, 8 years ago

Attachment: traceback.py added

Traceback

comment:1 by Tim Graham, 8 years ago

This is the same error as if you did MyModel.objects.get(coords=i.coords). I'm not a GeoDjango expert but perhaps the issue is that a subset of PostGIS spatial lookups are available for geography fields.

comment:2 by Tim Graham, 8 years ago

Component: UncategorizedGIS

comment:3 by Claude Paroz, 8 years ago

Resolution: invalid
Status: newclosed

Like Tim said, when using the geography flag, only a subset of methods are available.
See also http://postgis.net/docs/PostGIS_Special_Functions_Index.html#PostGIS_TypeFunctionMatrix (the geog column).

comment:4 by kemar, 8 years ago

Ok, understood. Thanx for the feedback.

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