def statement(self):
"""return the full SELECT statement represented by this Query."""
- return self._compile_context(labels=self._with_labels).statement
+ return self._compile_context(labels=self._with_labels).statement._annotate({'_halt_adapt': True})
statement = property(statement)
def subquery(self):
those being selected.
"""
- fromclause = self.compile().correlate(None)
+ fromclause = self.with_labels().statement.correlate(None)
self._statement = self._criterion = None
self._order_by = self._group_by = self._distinct = False
self._limit = self._offset = None
self.session._autoflush()
return self.session.scalar(s, params=self._params, mapper=self._mapper_zero())
- def compile(self):
- """compiles and returns a SQL statement based on the criterion and conditions within this Query."""
-
- return self._compile_context().statement
-
def _compile_context(self, labels=True):
context = QueryContext(self)
if context.eager_order_by:
statement.append_order_by(*context.eager_order_by)
-
- context.statement = statement._annotate({'_halt_adapt': True})
-
+
+ context.statement = statement
+
return context
def __log_debug(self, msg):
users.drop(tlengine)
tlengine.dispose()
+ def test_nested_unsupported(self):
+ self.assertRaises(NotImplementedError, tlengine.contextual_connect().begin_nested)
+ self.assertRaises(NotImplementedError, tlengine.begin_nested)
+
def test_connection_close(self):
"""test that when connections are closed for real, transactions are rolled back and disposed."""
'a1s': relation(A, secondary=c2a1, lazy=False),
'a2s': relation(A, secondary=c2a2, lazy=False)})
- assert create_session().query(C).compile()
+ assert create_session().query(C).with_labels().statement
+
+ # TODO: seems like just a test for an ancient exception throw.
+ # how about some data/inserts/queries/assertions for this one
if __name__ == "__main__":
def test_deferred(self):
session = create_session()
- s = session.query(User).filter(and_(addresses.c.email_address == bindparam('emailad'), Address.user_id==User.id)).compile()
+ s = session.query(User).filter(and_(addresses.c.email_address == bindparam('emailad'), Address.user_id==User.id)).statement
l = session.query(User).instances(s.execute(emailad = 'jack@bean.com'))
assert [User(id=7)] == l