On Oct 23, 7:16 pm, Aymeric Augustin
<aymeric.augus...@polytechnique.org> wrote:
> > Converters can be
> > registered per-column - the SELECT query would need to be tweaked to
> > hint to the SQLite libs to call the registered converter. I'm not sure
> > if that would be too intrusive to the existing Django query builder.
>
> I didn't know that. It could be useful to convert results of aggregation. At 
> the moment, I don't know how they are converted to Python types.

Aggregates can define if they are ordinal or computed. In practice
computed=True means the value returned will be converted to float,
ordinal=True means an integer. If none of the above is defined (which
would be the interesting case for datetimes) the source field for the
aggregate computation is used to define the return value. The
conversion is done in connection.ops.convert_values, which I guess is
the same place used when doing the conversion normally.

For your case, if the aggregate is going to return a timezone aware
datetime and for some reason the source field is not timezone aware
datetime field, you would need to refactor the sql.Aggregate class. I
guess this will not be a problem for you. It is likely things will
just work without any special handling for aggregates. On the other
hand, if you need to register a converter beforehand for an aggregate,
I don't think that is supported at all currently.

If you grep for 'is_ordinal' and 'resolve_aggregate' in db/models/sql
directory, you will find all the interesting places for aggregate type
conversion handling.

 - Anssi

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to