]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Fixed duplicate append event emission on repeated instrumented set.add() operations.
authorJason Kirtland <jek@discorporate.us>
Mon, 5 May 2008 17:08:00 +0000 (17:08 +0000)
committerJason Kirtland <jek@discorporate.us>
Mon, 5 May 2008 17:08:00 +0000 (17:08 +0000)
CHANGES
lib/sqlalchemy/orm/collections.py
test/orm/collection.py

diff --git a/CHANGES b/CHANGES
index dc7ff6a8ca108e0df3170560faddf863b1c08fde..9fe24ca815c705c921a3199bca778c2724dde444 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -53,10 +53,13 @@ CHANGES
     - same as [ticket:1019] but repaired the non-labeled use case
       [ticket:1022]
 
-    - Adjusted class-member inspection durint attribute and
+    - Adjusted class-member inspection during attribute and
       collection instrumentation that could be problematic when
       integrating with other frameworks.
 
+    - Fixed duplicate append event emission on repeated
+      instrumented set.add() operations.
+
 - declarative extension
     - Joined table inheritance mappers use a slightly relaxed
       function to create the "inherit condition" to the parent
index ae4cb65cde93bbb78fbd40823c90c31f7c3ec786..8067a030f7bf9a7629d2a43e144e563b3abf2371 100644 (file)
@@ -1148,7 +1148,8 @@ def _set_decorators():
 
     def add(fn):
         def add(self, value, _sa_initiator=None):
-            __set(self, value, _sa_initiator)
+            if value not in self:
+                __set(self, value, _sa_initiator)
             # testlib.pragma exempt:__hash__
             fn(self, value)
         _tidy(add)
@@ -1201,8 +1202,7 @@ def _set_decorators():
     def update(fn):
         def update(self, value):
             for item in value:
-                if item not in self:
-                    self.add(item)
+                self.add(item)
         _tidy(update)
         return update
 
@@ -1211,8 +1211,7 @@ def _set_decorators():
             if sautil.duck_type_collection(value) is not Set:
                 return NotImplemented
             for item in value:
-                if item not in self:
-                    self.add(item)
+                self.add(item)
             return self
         _tidy(__ior__)
         return __ior__
index 17c15876dd8f5a8e06f38fd061ecd9b43179b718..708ba9c744aa2c1e4a738b35a38a2f5b688f06da 100644 (file)
@@ -415,9 +415,12 @@ class CollectionsTest(TestBase):
                 direct.remove(item)
             control.clear()
 
-        # assume add() is available for list tests
         addall(creator())
 
+        e = creator()
+        addall(e)
+        addall(e)
+
         if hasattr(direct, 'pop'):
             direct.pop()
             control.pop()