﻿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
16408	Query result types not being converted with Spatialite	Antonio Eugenio Burriel <aeburriel@…>	jbronn	"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.
"	Bug	closed	GIS	1.5-beta-1	Normal	fixed	regression		Accepted	1	0	0	0	0	0
