On Sun, Mar 23, 2008 at 12:23 PM, Winsley von Spee <[EMAIL PROTECTED]>
wrote:

> perhaps I've just read over it, but how to you plan to handle not
> numeric types like datetime? In mysql you have to use something like
> "FROM_UNIXTIME(AVG(UNIX_TIMESTAMP(today))", but how should that be
> handled in the orm especially as its backend dependant.
>

There's quite a few things that are backend dependent. String concatenation
and dates are the big ones. Functions need a way to to get the proper SQL
from the backend, or delegate their whole behavior to a backend specified
class.

With backend-defined functions, you example would look something like
Date(Avg(Timestamp('date-col'))). (or possibly hide the explicit type
conversions to allow Avg('date_col'))

String concatenation is more difficult because to support using + requires a
type inference system so that 'a' + 'b' emits CONCAT('a','b') on mysql.

This is where open-ended expressions could get very complicated. Type
inference isn't so bad at first look, but I'm not completely familiar with
each databases coercion rules. It's possible that type inference has backend
dependancies too, and we would want to hide that from the programmer.

In a perfect world a valid expression should always work independent of the
backend (so the coercion should be conservative and support the least-common
denominator behavior), but in order for that to be true, then certain
expressions which would work with one backend but not another should fail
even when running on the backend that supports them.

This all could become very tricky very quickly, and it might be better to
pick a very limited subset of  functionality to support at first, like say
expressions only work with numbers, or numbers and dates. Something so that
the first version is simple and just works, but that doesn't get in the way
of supporting everything else in the future. For the time-being with
grouping and extra, the date averaging could be done with SQL.

-Justin

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

Reply via email to