On Aug 26, 2013, at 11:14 AM, lars van gemerden <[email protected]> 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 > 1.75
>
> is it possible to use this method to perform an sqla query on the database?
> Perhaps by using hybrid_method?
>
> Cheers, Lars
>
> PS: this might seem strange question, but it would save me a lot of work
> and/or would make my internal and user interfaces a lot more consistent.
>
> PPS: i do also have a string representation of the lambda functions, if that
> helps
I'm not sure if you need these to remain as lambdas, sure you can just pass it
to a hybrid_method:
class MyClass(Base):
# ....
@hybrid_method
def run_compare(self, fn, *args):
return fn(*args)
query(MyClass).filter(MyClass.run_compare(some_lambda, some_other_object))
>
> --
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/groups/opt_out.
signature.asc
Description: Message signed with OpenPGP using GPGMail
