merge stable
authorAlexandre Fayolle <alexandre.fayolle@logilab.fr>
Mon, 12 Apr 2010 15:11:23 +0200
branchstable
changeset 5215 b1327f19d23e
parent 5213 8604000bf3b2 (diff)
parent 5214 3285b6e3b930 (current diff)
child 5217 08e7fa906cdb
merge
--- a/devtools/__init__.py	Mon Apr 12 15:05:37 2010 +0000
+++ b/devtools/__init__.py	Mon Apr 12 15:11:23 2010 +0200
@@ -220,7 +220,7 @@
     driver = config.sources()['system']['db-driver']
     if driver == 'sqlite':
         reset_test_database_sqlite(config)
-    if driver == 'sqlserver2005':
+    elif driver == 'sqlserver2005':
         reset_test_database_sqlserver2005(config)
     else:
         raise ValueError('no reset function for driver %r' % driver)
@@ -241,7 +241,7 @@
     if config.init_repository:
         from cubicweb.server import init_repository
         init_repository(config, interactive=False, drop=True, vreg=vreg)
-        
+
 def reset_test_database_sqlserver2005(config):
     pass
 
--- a/server/ssplanner.py	Mon Apr 12 15:05:37 2010 +0000
+++ b/server/ssplanner.py	Mon Apr 12 15:11:23 2010 +0200
@@ -577,7 +577,7 @@
             result[i] = newrow
         # update entities
         for eid, edef in edefs.iteritems():
-            repo.glob_update_entity(session, edef, self.attributes)
+            repo.glob_update_entity(session, edef, set(self.attributes))
         return result
 
 def _handle_relterm(info, row, newrow):
--- a/server/test/unittest_repository.py	Mon Apr 12 15:05:37 2010 +0000
+++ b/server/test/unittest_repository.py	Mon Apr 12 15:11:23 2010 +0200
@@ -400,6 +400,27 @@
             self.assertRaises(AssertionError, req.create_entity,
                               'EmailAddress', address=u'a@b.fr')
 
+    def test_multiple_edit_set_attributes(self):
+        """make sure edited_attributes doesn't get cluttered
+        by previous entities on multiple set
+        """
+        # local hook
+        class DummyBeforeHook(Hook):
+            _test = self # keep reference to test instance
+            __regid__ = 'dummy-before-hook'
+            __select__ = Hook.__select__ & implements('Affaire')
+            events = ('before_update_entity',)
+            def __call__(self):
+                # invoiced attribute shouldn't be considered "edited" before the hook
+                self._test.failIf('invoiced' in self.entity.edited_attributes,
+                                  'edited_attributes cluttered by previous update')
+                self.entity['invoiced'] = 10
+        with self.temporary_appobjects(DummyBeforeHook):
+            req = self.request()
+            req.create_entity('Affaire', ref=u'AFF01')
+            req.create_entity('Affaire', ref=u'AFF02')
+            req.execute('SET A duration 10 WHERE A is Affaire')
+
 
 class DataHelpersTC(CubicWebTC):