]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Fix instance.__eq__() regression in orm attributes.
authorJason Kirtland <jek@discorporate.us>
Tue, 9 Feb 2010 22:38:00 +0000 (22:38 +0000)
committerJason Kirtland <jek@discorporate.us>
Tue, 9 Feb 2010 22:38:00 +0000 (22:38 +0000)
CHANGES
lib/sqlalchemy/orm/attributes.py

diff --git a/CHANGES b/CHANGES
index 13c5322ff288b01dad485c18554549a9912bcd05..27f3243a27ca5fa07490fe9a7e059b45e4d00b77 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -33,7 +33,10 @@ CHANGES
      returned statement, thus avoiding various SQL composition
      errors which can result from column name conflicts.
      [ticket:1676]
-     
+
+   - Fixed bug in attribute history that inadvertently invoked
+     __eq__ on mapped instances.
+
 - sql
   - Added math negation operator support, -x.
   
index 574df7d91aec212fc9d477a102a0d8c6e6c98423..662059af4053e0f666ee3510c9b7e6260360b429 100644 (file)
@@ -590,7 +590,9 @@ class ScalarObjectAttributeImpl(ScalarAttributeImpl):
 
     def fire_replace_event(self, state, dict_, value, previous, initiator):
         if self.trackparent:
-            if previous is not value and previous not in (None, PASSIVE_NO_RESULT):
+            if (previous is not value and
+                previous is not None and
+                previous is not PASSIVE_NO_RESULT):
                 self.sethasparent(instance_state(previous), False)
 
         for ext in self.extensions:
@@ -823,7 +825,7 @@ class GenericBackrefExtension(interfaces.AttributeExtension):
     def set(self, state, child, oldchild, initiator):
         if oldchild is child:
             return child
-        if oldchild not in (None, PASSIVE_NO_RESULT):
+        if oldchild is not None and oldchild is not PASSIVE_NO_RESULT:
             # With lazy=None, there's no guarantee that the full collection is
             # present when updating via a backref.
             old_state, old_dict = instance_state(oldchild), instance_dict(oldchild)
@@ -1244,10 +1246,16 @@ class History(tuple):
         
     def as_state(self):
         return History(
-            [c not in (None, PASSIVE_NO_RESULT) and instance_state(c) or None for c in self.added],
-            [c not in (None, PASSIVE_NO_RESULT) and instance_state(c) or None for c in self.unchanged],
-            [c not in (None, PASSIVE_NO_RESULT) and instance_state(c) or None for c in self.deleted],
-        )
+            [(c is not None and c is not PASSIVE_NO_RESULT)
+             and instance_state(c) or None
+             for c in self.added],
+            [(c is not None and c is not PASSIVE_NO_RESULT)
+             and instance_state(c) or None
+             for c in self.unchanged],
+            [(c is not None and c is not PASSIVE_NO_RESULT)
+             and instance_state(c) or None
+             for c in self.deleted],
+            )
     
     @classmethod
     def from_attribute(cls, attribute, state, current):
@@ -1271,7 +1279,9 @@ class History(tuple):
                 )
         else:
             if current is NO_VALUE:
-                if original not in [None, NEVER_SET, NO_VALUE]:
+                if (original is not None and
+                    original is not NEVER_SET and
+                    original is not NO_VALUE):
                     deleted = [original]
                 else:
                     deleted = ()