Cannot apply limit or offset when using ORM query.from_statement with not_ and exists
Assume tables a and b which have ORM classes A and B mapped.
stmt = a.select().where( not_( exists( b ).where( a.c.id == b.c.a_id ) ) ).order_by( a.c.id ) a_list = session.query( A ).from_statement( stmt ).offset( 10 ).limit( 5 )
a_list contains all element specified by stmt, regardless of offset and limit. If offset and limit are applied to stmt, the work as expected. Take out the not_ and it works as expected (though it has a different meaning, of course).
Python 2.5.2, sqlalchemy 0.4.6, mysql 4.1.23
Comments (2)
-
Account Deleted -
repo owner - changed status to invalid
from_statement() does not support further modifications to the query since SQLA does not necessarily know anything about the structure of the given statement (straight text for example). Your use case raises in error in 0.5. You mean to be using select_from().
- Log in to comment
For readability: