or_( *list_of..)
On Friday 06 March 2009 20:30:08 Tomasz Nazar wrote:
> Hi there,
>
> I have small issue and don't know how to solve ..
> I need to have this kind of query:
>
> q = dbsession().query(User).
> options(eagerload_all('lang_pairs.lang_a'),
> eagerload_all('lang_pairs.lang_a')).
>
> join(['lang_pairs']).
> filter(
> or_(
> and_(LangPair.a_lg_id == 'L1', LangPair.a_lg_id ==
> 'L2'), and_(LangPair.a_lg_id == 'L3', LangPair.a_lg_id == 'L4'),
> and_(LangPair.a_lg_id == 'L5', LangPair.a_lg_id == 'L6'), ....
> )
> )
>
> Obviously the part with many 'and_' clauses needs to be dynamicly
> created based on particular user search.
> How to achieve (generate dynamicaly) that?
>
> When I tried to do a list of 'and_' and put it into
> '...filter(or_(list_of_generated_ands))' SQLA told me:
> ArgumentError: filter() argument must be of type
> sqlalchemy.sql.ClauseElement or string
>
>
> Tomasz
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" 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/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---