Commits

Mike Bayer  committed 0e0f64b

- [bug] Fixed identity_key() function which
was not accepting a scalar argument
for the identity. [ticket:2508].

  • Participants
  • Parent commits a2aa962
  • Branches rel_0_7

Comments (0)

Files changed (3)

     flush() is no longer deprecated, as some
     valid use cases have been identified.  
 
+  - [bug] Fixed identity_key() function which 
+    was not accepting a scalar argument 
+    for the identity.  [ticket:2508].
+
 - engine
   - [bug] Fixed memory leak in C version of
     result proxy whereby DBAPIs which don't deliver

File lib/sqlalchemy/orm/util.py

                 % ", ".join(kwargs.keys()))
         mapper = class_mapper(class_)
         if "ident" in locals():
-            return mapper.identity_key_from_primary_key(ident)
+            return mapper.identity_key_from_primary_key(util.to_list(ident))
         return mapper.identity_key_from_row(row)
     instance = kwargs.pop("instance")
     if kwargs:

File test/orm/test_utils.py

         key = util.identity_key(User, ident=[1])
         eq_(key, (User, (1,)))
 
+    def test_identity_key_scalar(self):
+        User, users = self.classes.User, self.tables.users
+
+        mapper(User, users)
+
+        key = util.identity_key(User, 1)
+        eq_(key, (User, (1,)))
+        key = util.identity_key(User, ident=1)
+        eq_(key, (User, (1,)))
+
     def test_identity_key_2(self):
         users, User = self.tables.users, self.classes.User