server/migractions.py
branchstable
changeset 5551 e41cd3bf5080
parent 5426 0d4853a6e5ee
child 5552 11175c77be9c
--- a/server/migractions.py	Thu May 20 10:40:57 2010 +0200
+++ b/server/migractions.py	Thu May 20 10:41:36 2010 +0200
@@ -1200,11 +1200,15 @@
         source = self.repo.system_source
         storage = source.storage(etype, attribute)
         source.unset_storage(etype, attribute)
-        rset = self.rqlexec('Any X,A WHERE X is %s, X %s A'
-                            % (etype, attribute), ask_confirm=False)
+        rset = self.rqlexec('Any X WHERE X is %s' etype, ask_confirm=False)
         pb = ProgressBar(len(rset))
         for entity in rset.entities():
+            # fill cache. Do not fetch that attribute using the global rql query
+            # since we may exhaust memory doing that....
+            getattr(entity, attribute)
             storage.migrate_entity(entity, attribute)
+            # remove from entity cache to avoid memory exhaustion
+            del entity[attribute]
             pb.update()
         print
         source.set_storage(etype, attribute, storage)