due to an unnecessary lookup of the name
in the _decl_class_registry. [ticket:2194]
+ - Repaired the "no statement condition"
+ assertion in Query which would attempt
+ to raise if a generative method were called
+ after from_statement() were called.
+ [ticket:2199]. Also in 0.6.9.
+
- mssql
- Adjusted the pyodbc dialect such that bound
values are passed as bytes and not unicode
def _no_statement_condition(self, meth):
if not self._enable_assertions:
return
- if self._statement:
+ if self._statement is not None:
raise sa_exc.InvalidRequestError(
("Query.%s() being called on a Query with an existing full "
"statement - can't apply criterion.") % meth)
s = create_session()
- q = s.query(User).filter(User.id==5)
- assert_raises(sa_exc.InvalidRequestError, q.from_statement, "x")
-
- q = s.query(User).filter_by(id=5)
- assert_raises(sa_exc.InvalidRequestError, q.from_statement, "x")
-
- q = s.query(User).limit(5)
- assert_raises(sa_exc.InvalidRequestError, q.from_statement, "x")
-
- q = s.query(User).group_by(User.name)
- assert_raises(sa_exc.InvalidRequestError, q.from_statement, "x")
+ for meth, arg, kw in [
+ (Query.filter, (User.id==5,), {}),
+ (Query.filter_by, (), {'id':5}),
+ (Query.limit, (5, ), {}),
+ (Query.group_by, (User.name,), {}),
+ (Query.order_by, (User.name,), {})
+ ]:
+ q = s.query(User)
+ q = meth(q, *arg, **kw)
+ assert_raises(
+ sa_exc.InvalidRequestError,
+ q.from_statement, "x"
+ )
- q = s.query(User).order_by(User.name)
- assert_raises(sa_exc.InvalidRequestError, q.from_statement, "x")
+ q = s.query(User)
+ q = q.from_statement("x")
+ assert_raises(
+ sa_exc.InvalidRequestError,
+ meth, q, *arg, **kw
+ )
class OperatorTest(QueryTest, AssertsCompiledSQL):
"""test sql.Comparator implementation for MapperProperties"""