Commits

Mike Bayer committed 2e44d27

added items() method to RowProxy + unittest, courtesy dialtone@divmod.com

Comments (0)

Files changed (2)

lib/sqlalchemy/engine.py

             return self.__parent._get_col(self.__row, name)
         except:
             raise AttributeError
+    def items(self):
+        return [(key, getattr(self, key)) for key in self.keys()]
     def keys(self):
         return self.__parent.keys
     def values(self): 
         r = self.users.select().execute().fetchone()
         self.assertEqual(r.keys(), ['user_id', 'user_name'])
 
+    def test_items(self):
+        self.users.insert().execute(user_id=1, user_name='foo')
+        r = self.users.select().execute().fetchone()
+        self.assertEqual(r.items(), [('user_id', 1), ('user_name', 'foo')])
+
     def test_len(self):
         self.users.insert().execute(user_id=1, user_name='foo')
         r = self.users.select().execute().fetchone()