- fixed bug which was preventing synonym() attributes
from being used with inheritance
+
+ - Session.execute can now find binds from metadata
0.4.4
------
if self.bind is not None:
return self.bind
+ elif isinstance(clause, sql.expression.ClauseElement) and clause.bind is not None:
+ return clause.bind
elif mapper is None:
raise exceptions.UnboundExecutionError("Could not locate any mapper associated with SQL expression")
else:
sess.execute(users.insert(), params=dict(user_id=2, user_name='fred'))
assert sess.execute(users.select()).fetchall() == [(1, 'ed'), (2, 'fred')]
sess.close()
+
+ @engines.close_open_connections
+ def test_bind_from_metadata(self):
+ Session = sessionmaker()
+ sess = Session()
+ mapper(User, users)
+
+ sess.execute(users.insert(user_name='Johnny'))
+
+ assert len(sess.query(User).all()) == 1
+
+ sess.execute(users.delete())
+
+ assert len(sess.query(User).all()) == 0
+ sess.close()
@testing.unsupported('sqlite', 'mssql') # TEMP: test causes mssql to hang
@engines.close_open_connections