preventing conflicts with lazy loader operation, fixes
[ticket:308]
- fix to deferred group loading
+ - session.flush() wont close a connection it opened [ticket:346]
- added "batch=True" flag to mapper; if False, save_obj
will fully save one object at a time including calls
to before_XXXX and after_XXXX
e = connectable.engine
c = connectable.contextual_connect()
if not self.connections.has_key(e):
- self.connections[e] = (c, c.begin())
+ self.connections[e] = (c, c.begin(), c is not connectable)
return self.connections[e][0]
def commit(self):
if self.parent is not None:
if self.parent is not None:
return
for t in self.connections.values():
- t[0].close()
+ if t[2]:
+ t[0].close()
self.session.transaction = None
class Session(object):
from sqlalchemy import *
+class SessionTest(AssertMixin):
+ def setUpAll(self):
+ tables.create()
+ tables.data()
+ def tearDownAll(self):
+ tables.drop()
+ def tearDown(self):
+ tables.delete()
+ clear_mappers()
+ def setUp(self):
+ pass
+
+ def test_close(self):
+ """test that flush() doenst close a connection the session didnt open"""
+ c = testbase.db.connect()
+ class User(object):pass
+ mapper(User, users)
+ s = create_session(bind_to=c)
+ s.save(User())
+ s.flush()
+ c.execute("select * from users")
+
class OrphanDeletionTest(AssertMixin):
def setUpAll(self):
if isinstance(x['plain_data'], unicode):
# SQLLite returns even non-unicode data as unicode
self.assert_(db.name == 'sqlite')
+ self.assert_(x['plain_data'] == unicodedata)
self.echo("its sqlite !")
else:
self.assert_(not isinstance(x['plain_data'], unicode) and x['plain_data'] == rawdata)