in the database. Presents some degree of a workaround for
[ticket:1315], although we are considering removing the
flush([objects]) feature altogether.
+
+ - Session.scalar() now converts raw SQL strings to text()
+ the same way Session.execute() does and accepts same
+ alternative **kw args.
- improvements to the "determine direction" logic of
relation() such that the direction of tricky situations
return self.__connection(engine, close_with_result=True).execute(
clause, params or {})
- def scalar(self, clause, params=None, mapper=None):
+ def scalar(self, clause, params=None, mapper=None, **kw):
"""Like execute() but return a scalar result."""
-
- engine = self.get_bind(mapper, clause=clause)
-
- return self.__connection(engine, close_with_result=True).scalar(
- clause, params or {})
+
+ return self.execute(clause, params=params, mapper=mapper, **kw).scalar()
def close(self):
"""Close this Session.
{'id':7}).fetchall(),
[(7, u'jack')])
+
+ # use :bindparam style
+ eq_(sess.scalar("select id from users where id=:id",
+ {'id':7}),
+ 7)
+
@engines.close_open_connections
@testing.resolve_artifact_names
def test_subtransaction_on_external(self):