Commits

Anonymous committed b8b7800

Return the assigned value in MultableDict.setdefault

  • Participants
  • Parent commits ccad13d
  • Branches rel_0_9

Comments (0)

Files changed (2)

File lib/sqlalchemy/ext/mutable.py

 
 
     def setdefault(self, key, value):
-        dict.setdefault(self, key, value)
+        result = dict.setdefault(self, key, value)
         self.changed()
+        return result
 
     def __delitem__(self, key):
         """Detect dictionary del events and emit change events."""

File test/ext/test_mutable.py

         sess.add(f1)
         sess.commit()
 
-        f1.data.setdefault('c', 'd')
+        eq_(f1.data.setdefault('c', 'd'), 'd')
         sess.commit()
 
         eq_(f1.data, {'a': 'b', 'c': 'd'})
 
-        f1.data.setdefault('c', 'q')
+        eq_(f1.data.setdefault('c', 'q'), 'd')
         sess.commit()
 
         eq_(f1.data, {'a': 'b', 'c': 'd'})