id summary reporter owner description type status component version severity resolution keywords cc stage has_patch needs_docs needs_tests needs_better_patch easy ui_ux 10411 Updates do not work with GeometryFields jbronn Malcolm Tredinnick "{{{ >>> from world.models import * >>> mpoly = WorldBorders.objects.get(name='San Marino').mpoly >>> WorldBorders.objects.filter(name='Bahamas').update(mpoly=mpoly) Traceback (most recent call last): File """", line 1, in File ""/Users/jbronn/django/trunk/django/db/models/query.py"", line 450, in update rows = query.execute_sql(None) File ""/Users/jbronn/django/trunk/django/db/models/sql/subqueries.py"", line 119, in execute_sql cursor = super(UpdateQuery, self).execute_sql(result_type) File ""/Users/jbronn/django/trunk/django/db/models/sql/query.py"", line 2034, in execute_sql cursor.execute(sql, params) File ""/Users/jbronn/django/trunk/django/db/backends/util.py"", line 19, in execute return self.cursor.execute(sql, params) ProgrammingError: can't adapt }}} Looks like `GeoQuerySet.update()` doesn't work. It should be noted that `save()` (which uses `InsertQuery`) works because `ModelBase` pre-populates geometry field values through `get_db_prep_save` (which converts geom objects into database adaptor objects). This does not happen because `UpdateQuery` is invoked from the manager rather than at the model level and thus `get_db_prep_save` is never called and the database adaptor is left wondering why it got a `GEOSGeometry` object instead of something it can handle. A solution is to probably overload `GeoQuerySet.update` to properly go through and run through geometry field keywords through `get_db_prep_save`. For now the solution is to not use `.update()` with geometry fields and use the `.save()` model method instead." closed GIS 1.0 fixed gis update geoqueryset Accepted 1 0 0 0 0 0