fix bug when renaming a full text indexed attribute stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 02 Oct 2009 08:57:07 +0200
branchstable
changeset 3546 f0aecddf367e
parent 3544 188d86631c45
child 3547 0c18a6c8d9b7
fix bug when renaming a full text indexed attribute
entity.py
server/schemahooks.py
server/test/data/migratedapp/schema.py
server/test/data/schema.py
--- a/entity.py	Thu Oct 01 16:06:29 2009 +0200
+++ b/entity.py	Fri Oct 02 08:57:07 2009 +0200
@@ -924,8 +924,12 @@
         :return: the list of indexable word of this entity
         """
         from indexer.query_objects import tokenize
+        # take care to cases where we're modyfying the schema
+        pending = self.req.transaction_data.setdefault('pendingrdefs', set())
         words = []
         for rschema in self.e_schema.indexable_attributes():
+            if (self.e_schema, rschema) in pending:
+                continue
             try:
                 value = self.printable_value(rschema, format='text/plain')
             except TransformError:
--- a/server/schemahooks.py	Thu Oct 01 16:06:29 2009 +0200
+++ b/server/schemahooks.py	Fri Oct 02 08:57:07 2009 +0200
@@ -812,14 +812,15 @@
     """
     subjschema, rschema, objschema = session.schema.schema_by_eid(rdefeid)
     pendings = session.transaction_data.get('pendingeids', ())
+    pendingrdefs = session.transaction_data.setdefault('pendingrdefs', set())
     # first delete existing relation if necessary
     if rschema.is_final():
         rdeftype = 'CWAttribute'
+        pendingrdefs.add((subjschema, rschema))
     else:
         rdeftype = 'CWRelation'
+        pendingrdefs.add((subjschema, rschema, objschema))
         if not (subjschema.eid in pendings or objschema.eid in pendings):
-            pending = session.transaction_data.setdefault('pendingrdefs', set())
-            pending.add((subjschema, rschema, objschema))
             session.execute('DELETE X %s Y WHERE X is %s, Y is %s'
                             % (rschema, subjschema, objschema))
     execute = session.unsafe_execute
--- a/server/test/data/migratedapp/schema.py	Thu Oct 01 16:06:29 2009 +0200
+++ b/server/test/data/migratedapp/schema.py	Fri Oct 02 08:57:07 2009 +0200
@@ -88,7 +88,7 @@
 class Personne(EntityType):
     nom    = String(fulltextindexed=True, required=True, maxsize=64)
     prenom = String(fulltextindexed=True, maxsize=64)
-    civility   = String(maxsize=1, default='M')
+    civility   = String(maxsize=1, default='M', fulltextindexed=True)
     promo  = String(vocabulary=('bon','pasbon'))
     titre  = String(fulltextindexed=True, maxsize=128)
     adel   = String(maxsize=128)
--- a/server/test/data/schema.py	Thu Oct 01 16:06:29 2009 +0200
+++ b/server/test/data/schema.py	Fri Oct 02 08:57:07 2009 +0200
@@ -82,7 +82,7 @@
 class Personne(EntityType):
     nom    = String(fulltextindexed=True, required=True, maxsize=64)
     prenom = String(fulltextindexed=True, maxsize=64)
-    sexe   = String(maxsize=1, default='M')
+    sexe   = String(maxsize=1, default='M', fulltextindexed=True)
     promo  = String(vocabulary=('bon','pasbon'))
     titre  = String(fulltextindexed=True, maxsize=128)
     adel   = String(maxsize=128)