- attached contains.py
Can't use multiple filters in a query with relation.contains()
Issue #1058
resolved
If Bar has a many-to-many relation on Foo then Bar.query.filter(Bar.foos.contains(foo1)).filter(Bar.foos.contains(foo2))
does not currently work. In other words, contains() can be used to check if a relation contains a single specific element, but cannot be used to determine if it contains multiple specific elements.
The reason is that each contains() uses the same secondary table so an alias is needed, but right now no aliasing happens.
It works if we do "not_(...Contains(...))" instead of just "...Contains(...))" because each negated contains() generates a separate subquery.
Comments (4)
-
Account Deleted -
repo owner - marked as blocker
-
repo owner -
repo owner - removed milestone
Removing milestone: 0.4.xx (automated comment)
- Log in to comment
test case