[schema] rebuild computed attributes on schema reload
authorJulien Cristau <julien.cristau@logilab.fr>
Tue, 22 Dec 2015 11:35:43 +0100
changeset 11039 6424a2e112f5
parent 11038 7cb02ab4f321
child 11040 2c40ecf2a4fc
[schema] rebuild computed attributes on schema reload If we have new computed attributes we need to set their formula_select attribute or things get sad.
schema.py
server/test/unittest_migractions.py
--- a/schema.py	Tue Dec 22 10:39:05 2015 +0100
+++ b/schema.py	Tue Dec 22 11:35:43 2015 +0100
@@ -1134,6 +1134,7 @@
 
     def rebuild_infered_relations(self):
         super(CubicWebSchema, self).rebuild_infered_relations()
+        self.finalize_computed_attributes()
         self.finalize_computed_relations()
 
 
--- a/server/test/unittest_migractions.py	Tue Dec 22 10:39:05 2015 +0100
+++ b/server/test/unittest_migractions.py	Tue Dec 22 11:35:43 2015 +0100
@@ -914,8 +914,10 @@
         self.assertIn('note100', self.schema)
         with self.mh() as (cnx, mh):
             mh.cmd_sync_schema_props_perms('note100')
-        self.assertEqual(self.schema['note100'].rdefs['Note', 'Int'].formula,
-                         'Any N*100 WHERE X note N')
+        rdef = self.schema['note100'].rdefs['Note', 'Int']
+        self.assertEqual(rdef.formula_select.as_string(),
+                         'Any (N * 100) WHERE X note N, X is Note')
+        self.assertEqual(rdef.formula, 'Any N*100 WHERE X note N')
 
     def test_computed_attribute_sync_schema_props_perms_rdef(self):
         self.setup_add_score()