On Fri, Jan 30, 2009 at 2:47 AM, koenb <[email protected]> wrote:
>
> This is really great! Thanks all for the good work.
>
> Just curious, has there been any work done to make this also work for
> dates ?
>
> like in
>
> longevents = Event.objects.filter(enddate__gte=F('startdate')+10)

As committed, the expressions framework is fairly dumb - it is really
just a way to do two things:
 1) Expand Django-style field references into column names (and joins
if required)
 2) Turn Python expression trees into SQL expression trees.

This means that the operations that are allowed depend somewhat on the
database in use. For example, on MySQL, you can perform mod operations
on floats; under Postgres, you can't.

Constants in expressions are rendered as-is, so whether dates are
allowed depends on what your database allows. From some quick tests,
date + integer works on SQLite and MySQL -- or, at least, doesn't
throw an error. I haven't confirmed that the answer it gives is
actually meaningful. Postgres complains with an error "operator does
not exist: timestamp with time zone + integer".

However, I'm certainly interested in entertaining any modification to
support more interesting expressions - for example, converting the
expression "F('date') + timedelta(days=3)" into meaningful SQL.
Patches welcome.

Yours,
Russ Magee %-)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" 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-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to