#14462: Aggregates default to the database type instead of the field type
-----------------------------------------------+----------------------------
 Reporter:  WoLpH                              |       Owner:  nobody    
   Status:  new                                |   Milestone:            
Component:  Database layer (models, ORM)       |     Version:  1.2       
 Keywords:  aggregate, annotate, type, coerce  |       Stage:  Unreviewed
Has_patch:  0                                  |  
-----------------------------------------------+----------------------------
 First a little background information, I've got a couple of custom field
 types which get cast right after loading the model.
 So instead of a Decimal I get a Euro object with added features like
 formatting and stuff like that.

 However, it seems that the aggregate/annotate queries in Django do not
 respect the `to_python()` method but simply cast to the type specified by
 the database backend.
 This can easily be fixed by modifying `convert_values()` so it returns
 this:
 {{{
 #!python
 return field.to_python(connection.ops.convert_values(value, field))
 }}}

 instead of
 {{{
 #!python
 return connection.ops.convert_values(value, field)
 }}}

 The `convert_values()` function:
 
http://code.djangoproject.com/browser/django/trunk/django/db/models/sql/query.py#L298


 Would this be the proper location to fix this? Either way, it has to be a
 bug that the `max()` of a value returns a different type.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/14462>
Django <http://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-upda...@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.

Reply via email to