only get value when necessary to check uniqueness
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 02 Sep 2009 10:53:51 +0200
changeset 3086 94ed8f0f0d14
parent 3085 b415bca9a9ed
child 3087 dbbaa628f0f9
only get value when necessary to check uniqueness
hooks/integrity.py
--- a/hooks/integrity.py	Wed Sep 02 10:24:15 2009 +0200
+++ b/hooks/integrity.py	Wed Sep 02 10:53:51 2009 +0200
@@ -163,11 +163,11 @@
         entity = self.entity
         eschema = entity.e_schema
         for attr in entity.edited_attributes:
-            val = entity[attr]
-            if val is None:
-                continue
             if eschema.subject_relation(attr).is_final() and \
                    eschema.has_unique_values(attr):
+                val = entity[attr]
+                if val is None:
+                    continue
                 rql = '%s X WHERE X %s %%(val)s' % (entity.e_schema, attr)
                 rset = self._cw.unsafe_execute(rql, {'val': val})
                 if rset and rset[0][0] != entity.eid: