Commits

Mike Bayer  committed f4a3e1b

- disabled the "populate expired/deferred attributes as we come across them" functionality in mapper._instance(), as its not completed, doesn't properly handle mutable scalar attributes, and has poor test coverage

  • Participants
  • Parent commits 6821e86

Comments (0)

Files changed (2)

File lib/sqlalchemy/orm/mapper.py

             if 'populate_instance' not in extension.methods or extension.populate_instance(self, context, row, instance, only_load_props=only_load_props, instancekey=identitykey, isnew=isnew) is EXT_CONTINUE:
                 self.populate_instance(context, instance, row, only_load_props=only_load_props, instancekey=identitykey, isnew=isnew)
 
-        elif getattr(state, 'expired_attributes', None):
-            # TODO: dont base this off of 'expired_attrbutes' - base it off of unloaded attrs, possibly
-            # based on the state.callables collection.  
-            attrs = state.expired_attributes.intersection(state.unmodified)
-            if 'populate_instance' not in extension.methods or extension.populate_instance(self, context, row, instance, only_load_props=attrs, instancekey=identitykey, isnew=isnew) is EXT_CONTINUE:
-                self.populate_instance(context, instance, row, only_load_props=attrs, instancekey=identitykey, isnew=isnew)
+#       NOTYET: populate attributes on non-loading instances which have been expired, deferred, etc.
+#        elif getattr(state, 'expired_attributes', None):   # TODO: base off total set of unloaded attributes, not just exp
+#            attrs = state.expired_attributes.intersection(state.unmodified)
+#            if 'populate_instance' not in extension.methods or extension.populate_instance(self, context, row, instance, only_load_props=attrs, instancekey=identitykey, isnew=isnew) is EXT_CONTINUE:
+#                self.populate_instance(context, instance, row, only_load_props=attrs, instancekey=identitykey, isnew=isnew)
+#            context.partials.add((state, attrs))  <-- allow query.instances to commit the subset of attrs
             
         if result is not None and ('append_result' not in extension.methods or extension.append_result(self, context, row, instance, result, instancekey=identitykey, isnew=isnew) is EXT_CONTINUE):
             result.append(instance)
             existing_populators = []
             post_processors = []
             for prop in self.__props.values():
-                if only_load_props and prop.key not in only_load_props:
-                    continue
                 (newpop, existingpop, post_proc) = selectcontext.exec_with_path(self, prop.key, prop.create_row_processor, selectcontext, self, row)
                 if newpop is not None:
                     new_populators.append((prop.key, newpop))

File test/orm/expire.py

         sess.expire(u)
         # object isnt refreshed yet, using dict to bypass trigger
         assert u.__dict__.get('name') != 'jack'
-        # reload all
-        sess.query(User).all()
-        # test that it refreshed
-        assert u.__dict__['name'] == 'jack'
 
-        def go():
-            assert u.name == 'jack'
-        self.assert_sql_count(testbase.db, go, 0)
+        if False:
+            # NOTYET: need to implement unconditional population
+            # of expired attriutes in mapper._instances()
+            sess.query(User).all()
+            # test that it refreshed
+            assert u.__dict__['name'] == 'jack'
+
+            def go():
+                assert u.name == 'jack'
+            self.assert_sql_count(testbase.db, go, 0)
     
     def test_expire_doesntload_on_set(self):
         mapper(User, users)
         assert o.isopen == 1
         assert o.description == 'some new description'
         
-        sess.expire(o, ['isopen', 'description'])
-        sess.query(Order).all()
-        del o.isopen
-        def go():
-            assert o.isopen is None
-        self.assert_sql_count(testbase.db, go, 0)
+        if False:
+            # NOTYET: need to implement unconditional population
+            # of expired attriutes in mapper._instances()
+            sess.expire(o, ['isopen', 'description'])
+            sess.query(Order).all()
+            del o.isopen
+            def go():
+                assert o.isopen is None
+            self.assert_sql_count(testbase.db, go, 0)
         
     def test_expire_committed(self):
         """test that the committed state of the attribute receives the most recent DB data"""