[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.
--- 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()