Opened 9 years ago

Closed 8 years ago

#26788 closed Bug (fixed)

update of geometry field from the another one crashes

Reported by: Sergey Fedoseev Owned by: Sergey Fedoseev
Component: GIS Version: 1.9
Severity: Normal Keywords:
Cc: 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

class City(models.Model):
    point = models.PointField(srid=4326)
    point2 = models.PointField(srid=3857, null=True)
City.objects.update(point2=models.F('point'))
<ipython-input-7-e6630ea1824e> in <module>()
----> 1 City.objects.update(point2=models.F('point'))

/home/sergey/dev/django/django/db/models/manager.pyc in manager_method(self, *args, **kwargs)
     83         def create_method(name, method):
     84             def manager_method(self, *args, **kwargs):
---> 85                 return getattr(self.get_queryset(), name)(*args, **kwargs)
     86             manager_method.__name__ = method.__name__
     87             manager_method.__doc__ = method.__doc__

/home/sergey/dev/django/django/db/models/query.pyc in update(self, **kwargs)
    634         query.add_update_values(kwargs)
    635         with transaction.atomic(using=self.db, savepoint=False):
--> 636             rows = query.get_compiler(self.db).execute_sql(CURSOR)
    637         self._result_cache = None
    638         return rows

/home/sergey/dev/django/django/db/models/sql/compiler.pyc in execute_sql(self, result_type)
   1146         related queries are not available.
   1147         """
-> 1148         cursor = super(SQLUpdateCompiler, self).execute_sql(result_type)
   1149         try:
   1150             rows = cursor.rowcount if cursor else 0

/home/sergey/dev/django/django/db/models/sql/compiler.pyc in execute_sql(self, result_type)
    822             result_type = NO_RESULTS
    823         try:
--> 824             sql, params = self.as_sql()
    825             if not sql:
    826                 raise EmptyResultSet

/home/sergey/dev/django/django/db/models/sql/compiler.pyc in as_sql(self)
   1114             # Getting the placeholder for the field.
   1115             if hasattr(field, 'get_placeholder'):
-> 1116                 placeholder = field.get_placeholder(val, self, self.connection)
   1117             else:
   1118                 placeholder = '%s'

/home/sergey/dev/django/django/contrib/gis/db/models/fields.pyc in get_placeholder(self, value, compiler, connection)
    159         given value.
    160         """
--> 161         return connection.ops.get_geom_placeholder(self, value, compiler)
    162 
    163     def get_srid(self, obj):

/home/sergey/dev/django/django/contrib/gis/db/backends/postgis/operations.pyc in get_geom_placeholder(self, f, value, compiler)
    338             value_srid = get_pgraster_srid(value)
    339         else:
--> 340             value_srid = value.srid
    341 
    342         # Adding Transform() to the SQL placeholder if the value srid

AttributeError: 'Col' object has no attribute 'srid'

Change History (10)

comment:1 by Sergey Fedoseev, 9 years ago

Owner: changed from nobody to Sergey Fedoseev
Status: newassigned

comment:2 by Tim Graham, 9 years ago

Triage Stage: UnreviewedAccepted

comment:3 by Sergey Fedoseev, 8 years ago

Has patch: set

comment:4 by Sergey Fedoseev, 8 years ago

Patch needs improvement: set

comment:5 by Sergey Fedoseev, 8 years ago

Has patch: unset
Patch needs improvement: unset

My patch should be reworked, I will try do it in the near future.

comment:6 by Sergey Fedoseev, 8 years ago

Has patch: set

PR is updated.

comment:7 by Tim Graham, 8 years ago

Patch needs improvement: set

A couple of Oracle failures remain.

comment:8 by Sergey Fedoseev, 8 years ago

Patch needs improvement: unset

These failures are fixed now.

comment:9 by Tim Graham, 8 years ago

Triage Stage: AcceptedReady for checkin

comment:10 by Tim Graham <timograham@…>, 8 years ago

Resolution: fixed
Status: assignedclosed

In e7afef1:

Fixed #26788 -- Fixed QuerySet.update() crash when updating a geometry to another one.

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