]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- [bug] Fixed identity_key() function which
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 11 Jun 2012 14:08:33 +0000 (10:08 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 11 Jun 2012 14:08:33 +0000 (10:08 -0400)
was not accepting a scalar argument
for the identity.  [ticket:2508]. Also
in 0.7.8.

CHANGES
lib/sqlalchemy/orm/util.py
test/orm/test_utils.py

diff --git a/CHANGES b/CHANGES
index a57f0aa87ac5cea491037bfbdc8be9f4a4b8e4ae..c29ea98a451eedcb7c85975ca88640e7d8078e9a 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -136,6 +136,11 @@ CHANGES
     valid use cases have been identified.  
     Also in 0.7.8.
 
+  - [bug] Fixed identity_key() function which 
+    was not accepting a scalar argument 
+    for the identity.  [ticket:2508]. Also
+    in 0.7.8.
+
   - [feature] Query now "auto correlates" by 
     default in the same way as select() does.
     Previously, a Query used as a subquery
index 8403ce6738912cd022ab77bdda46457937ec8955..51aaa31524a9fdc964fba2d3c328e887ccadbbc0 100644 (file)
@@ -199,7 +199,7 @@ def identity_key(*args, **kwargs):
                 % ", ".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:
index 62a8500bd4cce60f9ffab944f876834ef936f6c8..617f1d5384f9c38f2db1f17ebadd004f68c042d5 100644 (file)
@@ -198,6 +198,16 @@ class IdentityKeyTest(_fixtures.FixtureTest):
         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