[sqlalchemy] alternate way to filter queries

2013-08-26 Thread lars van gemerden
Hi all, This might be a bit of a stretch but here it goes: Say that i have a lambda function that takes a mapped object and teturns whether it is valid; e.g: lambda person: person.age 17 or person.length 1.75 is it possible to use this method to perform an sqla query on the database?

Re: [sqlalchemy] alternate way to filter queries

2013-08-26 Thread Michael Bayer
On Aug 26, 2013, at 11:14 AM, lars van gemerden l...@rational-it.com wrote: Hi all, This might be a bit of a stretch but here it goes: Say that i have a lambda function that takes a mapped object and teturns whether it is valid; e.g: lambda person: person.age 17 or person.length

Re: [sqlalchemy] alternate way to filter queries

2013-08-26 Thread lars van gemerden
Hi Michael, So just to be sure, if i understand correctly and i have: func = lambda person: person.age 17 or person.length 1.75 I can do: class Person(Base): # @hybrid_method def run_filter(self, fn): return fn(self)

Re: [sqlalchemy] alternate way to filter queries

2013-08-26 Thread Simon King
On 26 Aug 2013, at 19:15, lars van gemerden l...@rational-it.com wrote: On Monday, August 26, 2013 5:23:07 PM UTC+2, Michael Bayer wrote: On Aug 26, 2013, at 11:14 AM, lars van gemerden la...@rational-it.com wrote: Hi all, This might be a bit of a stretch but here it goes: Say that

Re: [sqlalchemy] alternate way to filter queries

2013-08-26 Thread Michael Bayer
oh , the or won't work as a hybrid, you either need to use the binary op | or otherwise run through some filter that will give you expression vs. local behavior. On Aug 26, 2013, at 2:15 PM, lars van gemerden l...@rational-it.com wrote: Hi Michael, So just to be sure, if i understand

Re: [sqlalchemy] alternate way to filter queries

2013-08-26 Thread lars van gemerden
Hmm, too bad. I do have the lambda methods in string form so i'll probably have to write a parser and construct the query with unions and intersects (or filter(A.b 1, A.c0) like calls instead of intersects). No how did writing a parser tree go |-)? CL On Monday, August 26, 2013 8:27:16 PM