1. idank
  2. sqlalchemy

Commits

Mike Bayer  committed c860be0

- Added "add()" and "add_all()" to scoped_session
methods. Workaround for 0.4.7:

from sqlalchemy.orm.scoping import ScopedSession,\
instrument
setattr(
ScopedSession, "add", instrument("add"))
setattr(
ScopedSession, "add_all", instrument("add_all"))

  • Participants
  • Parent commits feb03a8
  • Branches rel_0_4

Comments (0)

Files changed (4)

File CHANGES

View file
  • Ignore whitespace
 =======
 CHANGES
 =======
-
+0.4.8
+=====
+- orm 
+    - Added "add()" and "add_all()" to scoped_session
+      methods.  Workaround for 0.4.7:
+      
+        from sqlalchemy.orm.scoping import ScopedSession,\
+        instrument
+        setattr(
+            ScopedSession, "add", instrument("add"))
+        setattr(
+            ScopedSession, "add_all", instrument("add_all"))
+        
 0.4.7
 =====
 - orm

File VERSION

View file
  • Ignore whitespace
-0.4.7
+0.4.8

File lib/sqlalchemy/orm/scoping.py

View file
  • Ignore whitespace
     def do(self, *args, **kwargs):
         return getattr(self.registry(), name)(*args, **kwargs)
     return do
-for meth in ('get', 'load', 'close', 'save', 'commit', 'update', 'save_or_update', 'flush', 'query', 'delete', 'merge', 'clear', 'refresh', 'expire', 'expunge', 'rollback', 'begin', 'begin_nested', 'connection', 'execute', 'scalar', 'get_bind', 'is_modified', '__contains__', '__iter__'):
+for meth in ('add', 'add_all', 'get', 'load', 'close', 'save', 'commit', 'update', 'save_or_update', 'flush', 'query', 'delete', 'merge', 'clear', 'refresh', 'expire', 'expunge', 'rollback', 'begin', 'begin_nested', 'connection', 'execute', 'scalar', 'get_bind', 'is_modified', '__contains__', '__iter__'):
     setattr(ScopedSession, meth, instrument(meth))
 
 def makeprop(name):

File test/orm/session.py

View file
  • Ignore whitespace
         self.assertEquals(SomeObject(id=1, data="hello", options=[SomeOtherObject(someid=1)]), Session.query(SomeObject).one())
         self.assertEquals(SomeObject(id=1, data="hello", options=[SomeOtherObject(someid=1)]), SomeObject.query.one())
         self.assertEquals(SomeOtherObject(someid=1), SomeOtherObject.query.filter(SomeOtherObject.someid==sso.someid).one())
-
+    
+    def test_forwards_compat_add(self):
+        Session = scoped_session(sessionmaker())
+        class User(object):
+            pass
+        
+        mapper(User, table)
+        u1 = User()
+        Session.add(u1)
+        assert u1 in Session()
+        
+        u2, u3 = User(), User()
+        Session.add_all([u2, u3])
+        assert u2 in Session()
+        assert u3 in Session()
+        
 class ScopedMapperTest(TestBase):
     def setUpAll(self):
         global metadata, table, table2