[Sqlalchemy-tickets] Issue #3083: clarify filter_by() (non-)interaction with select_from() (zzzeek/
Brought to you by:
zzzeek
|
From: Sebastian B. <iss...@bi...> - 2014-06-17 09:33:35
|
New issue 3083: clarify filter_by() (non-)interaction with select_from() https://bitbucket.org/zzzeek/sqlalchemy/issue/3083/clarify-filter_by-non-interaction-with Sebastian Bank: When using `filter_by` to simplify `filter` expressions session.query(User).filter(User.id == 1) session.query(User).filter_by(id=1) where `filter_by` applies to the last join entity session.query(User).join(user_group).filter(user_group.c.group_id == 5) session.query(User).join(user_group).filter_by(group_id=5) I stumbled on the fact that it does not follow a `select_from` (which I expected intuitively): session.query(User).select_from(user_group).filter(user_group.c.group_id == 5).join(User) session.query(User).select_from(user_group).filter_by(group_id=5).join(User) The second one fails. In my concrete case, the primary entity actually had an attribute with the same name. Hence, I ended up with the wrong filter condition (discovering that much later). Maybe a hint in the documentation of `filter_by` and/or `select_from` could help so that others don't make the same mistake. In the long run, I might also suggest to change this behaviour. |