Michael Bayer | 27 May 17:14

Re: filtering by datetime elements


On May 27, 2008, at 10:56 AM, Roger Demetrescu wrote:

>
> On Sat, May 17, 2008 at 12:17 PM,  <az <at> svilendobrev.com> wrote:
>
>> wishlist suggestion: how about type-related attributes on columns,
>> using which will autogenerate some expr off that column?
>> e.g. select( mytable.c.mydate.year == '1998') to automagicaly yield
>> something like func.substr(mytable.c.mydate,1,4)) == '1998'
>> (supposing the type of mydate stores datetime as yyyymmdd string)
>
> That sounds interesting...
>
> +1 on that...  :)
>
>
> Michael, is that feasible / desirable for SA 0.5 ?

not really since its fairly arbitrary and redundant against using  
func.XXX().    Anytime we start sticking .XXX on an object of some  
type, we start hitting a namespace problem, and magical stuff like  
this invariably causes many more problems than it solves (witness  
assign_mapper()).   This one is a lot worse than assign_mapper() since  
the specific group of names available would be different based on  
column type.  if you think of all the functions that could be had off  
of all the different datatypes across all the different database  
implementations, this becomes an enormous job.

Also the usual use case for dateparts is that of comparison to a  
coarse-grained date (like a year), and its more efficient from a SQL  
perspective to compare to date ranges instead.

We do want to eventually get generic "datepart" functionality under  
the "func" namespace.  thats would alleviate most of the headache of  
using DB-specific datepart functions.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To post to this group, send email to sqlalchemy <at> googlegroups.com
To unsubscribe from this group, send email to sqlalchemy-unsubscribe <at> googlegroups.com
For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---


Gmane