- changed component to orm
session.flush() closes the undelying connectable in all cases
Issue #346
resolved
from sqlalchemy import *
eng = create_engine('sqlite://')
conn=eng.connect()
class User(object):pass
users = Table('users', MetaData(), Column('id', Integer, primary_key=True), Column('name', String(30)))
users.create(connectable=conn)
mapper(User, users)
session = create_session(bind_to=conn)
session.save(User())
query=session.query(User)
query=query.select_by_name
listofpeople=query("Doe")
session.flush()
listofpeople=query("Smith")
raises "this connection is closed" on the query.
probable patch is this, but would like unit tests to make sure all combinations work properly (add to session.py unit tests)
Index: lib/sqlalchemy/orm/session.py
===================================================================
--- lib/sqlalchemy/orm/session.py (revision 1852)
+++ lib/sqlalchemy/orm/session.py (working copy)
@@ -37,7 +37,7 @@
e = connectable.engine
c = connectable.contextual_connect()
if not self.connections.has_key(e):
- self.connections[e](e) = (c, c.begin())
+ self.connections[e](e) = (c, c.begin(), c is not connectable)
return self.connections[e](e)[0](0)
def commit(self):
if self.parent is not None:
@@ -58,7 +58,8 @@
if self.parent is not None:
return
for t in self.connections.values():
- t[0](0).close()
+ if (t[2](2)):
+ t[0](0).close()
self.session.transaction = None
class Session(object):
Comments (3)
-
reporter -
reporter - changed status to resolved
-
reporter - removed milestone
Removing milestone: 0.3.0 (automated comment)
- Log in to comment