#16408: Query result types not being converted with Spatialite -------------------------------------------------+------------------------- Reporter: Antonio Eugenio Burriel | Owner: nobody <aeburriel@…> | Status: new Type: Bug | Component: GIS Milestone: | Severity: Normal Version: 1.3 | Triage Stage: Keywords: | Unreviewed Has patch: 0 | Easy pickings: 0 UI/UX: 0 | -------------------------------------------------+------------------------- While making a model gis-aware, I've noticed the following wrong behavior with the Spatialite backend (works as expected with Postgis).
Consider the following model: {{{ from django.contrib.gis.db import models class Demo(models.Model): timestamp = models.DateTimeField(auto_now_add=True) number = models.DecimalField(decimal_places=2, max_digits=5) # objects = models.GeoManager() # Disabled on purpose }}} Open a django shell and populate the model: {{{ from demo.models import Demo from django.contrib.gis.db.models import * Demo(number="13.22").save() }}} A simple query {{{ >>> Demo.objects.all().values() [{'timestamp': datetime.datetime(2011, 7, 4, 16, 8, 26, 297486), 'id': 1, 'number': Decimal('13.22')}] }}} So far, so good {{{ >>> Demo.objects.aggregate(Min("number"), Min("timestamp")) {'number__min': Decimal('13.22'), 'timestamp__min': datetime.datetime(2011, 7, 4, 16, 8, 26, 297486)} }}} Just as expected. Let's do it again, this time enabling the GeoManager: {{{ from django.contrib.gis.db import models class Demo(models.Model): timestamp = models.DateTimeField(auto_now_add=True) number = models.DecimalField(decimal_places=2, max_digits=5) objects = models.GeoManager() }}} {{{ from demo.models import Demo from django.contrib.gis.db.models import * }}} {{{ >>> Demo.objects.all().values() [{'timestamp': datetime.datetime(2011, 7, 4, 16, 8, 26, 297486), 'id': 1, 'number': Decimal('13.22')}] }}} The same... Now... {{{ >>> Demo.objects.aggregate(Min("number"), Min("timestamp")) {'number__min': 13.220000000000001, 'timestamp__min': u'2011-07-04 16:08:26.297486'} }}} Whoops! '''float and string instead of Decimal and datetime'''! See the difference? With GeoManager. convert_values() seems not to be called, at least for DateQuerySets and aggregates. -- Ticket URL: <https://code.djangoproject.com/ticket/16408> 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 post to this group, send email to django-updates@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.