[migration] always rebuild infered relation
This was skipped for some bad reason (see 12ad88615a12 which
introduced the change).
Fix for #231956 in Yams is necessary to allow this cset: during a
migration, we want to always reinfer relations while allowing explicit
redefinition of an infered relation later. Else, we may run the
migration with missing parts of the schema (the one that should have
been infered).
Closes #3685463.
--- a/__pkginfo__.py Mon Mar 24 16:29:18 2014 +0100
+++ b/__pkginfo__.py Thu Mar 27 14:32:21 2014 +0100
@@ -42,7 +42,7 @@
'logilab-common': '>= 0.60.0',
'logilab-mtconverter': '>= 0.8.0',
'rql': '>= 0.31.2',
- 'yams': '>= 0.39.0',
+ 'yams': '>= 0.39.1',
#gettext # for xgettext, msgcat, etc...
# web dependancies
'simplejson': '>= 2.0.9',
--- a/cubicweb.spec Mon Mar 24 16:29:18 2014 +0100
+++ b/cubicweb.spec Thu Mar 27 14:32:21 2014 +0100
@@ -23,7 +23,7 @@
Requires: %{python}-logilab-common >= 0.60.0
Requires: %{python}-logilab-mtconverter >= 0.8.0
Requires: %{python}-rql >= 0.31.2
-Requires: %{python}-yams >= 0.39.0
+Requires: %{python}-yams >= 0.39.1
Requires: %{python}-logilab-database >= 1.11.0
Requires: %{python}-passlib
Requires: %{python}-lxml
--- a/debian/control Mon Mar 24 16:29:18 2014 +0100
+++ b/debian/control Thu Mar 27 14:32:21 2014 +0100
@@ -15,7 +15,7 @@
python-unittest2 | python (>= 2.7),
python-logilab-mtconverter,
python-rql,
- python-yams (>= 0.39),
+ python-yams (>= 0.39.1),
python-lxml,
Standards-Version: 3.9.1
Homepage: http://www.cubicweb.org
@@ -153,7 +153,7 @@
gettext,
python-logilab-mtconverter (>= 0.8.0),
python-logilab-common (>= 0.60.0),
- python-yams (>= 0.39.0),
+ python-yams (>= 0.39.1),
python-rql (>= 0.31.2),
python-lxml
Recommends:
--- a/hooks/syncschema.py Mon Mar 24 16:29:18 2014 +0100
+++ b/hooks/syncschema.py Thu Mar 27 14:32:21 2014 +0100
@@ -1,4 +1,4 @@
-# copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2014 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of CubicWeb.
@@ -196,13 +196,11 @@
clear_cache(eschema, 'ordered_relations')
def postcommit_event(self):
- rebuildinfered = self.session.data.get('rebuild-infered', True)
repo = self.session.repo
# commit event should not raise error, while set_schema has chances to
# do so because it triggers full vreg reloading
try:
- if rebuildinfered:
- repo.schema.rebuild_infered_relations()
+ repo.schema.rebuild_infered_relations()
# trigger vreg reload
repo.set_schema(repo.schema)
# CWUser class might have changed, update current session users
--- a/server/migractions.py Mon Mar 24 16:29:18 2014 +0100
+++ b/server/migractions.py Thu Mar 27 14:32:21 2014 +0100
@@ -1,4 +1,4 @@
-# copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2014 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of CubicWeb.
@@ -102,7 +102,6 @@
# no config on shell to a remote instance
if config is not None and (cnx or connect):
repo = self.repo
- self.session.data['rebuild-infered'] = False
# register a hook to clear our group_mapping cache and the
# self._synchronized set when some group is added or updated
ClearGroupMap.mih = self
@@ -292,7 +291,6 @@
print 'aborting...'
sys.exit(0)
self.session.keep_cnxset_mode('transaction')
- self.session.data['rebuild-infered'] = False
return self._cnx
@property
--- a/server/test/unittest_migractions.py Mon Mar 24 16:29:18 2014 +0100
+++ b/server/test/unittest_migractions.py Thu Mar 27 14:32:21 2014 +0100
@@ -1,4 +1,4 @@
-# copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2014 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of CubicWeb.
@@ -225,7 +225,6 @@
self.assertTrue(self.session.execute('CWEType X WHERE X name "Folder2"'))
self.assertTrue('filed_under2' in self.schema)
self.assertTrue(self.session.execute('CWRType X WHERE X name "filed_under2"'))
- self.schema.rebuild_infered_relations()
self.assertEqual(sorted(str(rs) for rs in self.schema['Folder2'].subject_relations()),
['created_by', 'creation_date', 'cw_source', 'cwuri',
'description', 'description_format',
@@ -271,7 +270,6 @@
def test_add_drop_relation_type(self):
self.mh.cmd_add_entity_type('Folder2', auto=False)
self.mh.cmd_add_relation_type('filed_under2')
- self.schema.rebuild_infered_relations()
self.assertTrue('filed_under2' in self.schema)
# Old will be missing as it has been renamed into 'New' in the migrated
# schema while New hasn't been added here.
@@ -328,17 +326,11 @@
self.assertEqual(sorted(str(e) for e in self.schema['concerne'].subjects()),
['Affaire', 'Personne'])
self.assertEqual(sorted(str(e) for e in self.schema['concerne'].objects()),
- ['Affaire', 'Division', 'Note', 'SubDivision'])
- self.schema.rebuild_infered_relations() # need to be explicitly called once everything is in place
- self.assertEqual(sorted(str(e) for e in self.schema['concerne'].objects()),
['Affaire', 'Note'])
self.mh.cmd_add_relation_definition('Affaire', 'concerne', 'Societe')
self.assertEqual(sorted(str(e) for e in self.schema['concerne'].subjects()),
['Affaire', 'Personne'])
self.assertEqual(sorted(str(e) for e in self.schema['concerne'].objects()),
- ['Affaire', 'Note', 'Societe'])
- self.schema.rebuild_infered_relations() # need to be explicitly called once everything is in place
- self.assertEqual(sorted(str(e) for e in self.schema['concerne'].objects()),
['Affaire', 'Division', 'Note', 'Societe', 'SubDivision'])
# trick: overwrite self.maxeid to avoid deletion of just reintroduced types
self.maxeid = self.session.execute('Any MAX(X)')[0][0]
@@ -599,12 +591,10 @@
@tag('longrun')
def test_introduce_base_class(self):
self.mh.cmd_add_entity_type('Para')
- self.mh.repo.schema.rebuild_infered_relations()
self.assertEqual(sorted(et.type for et in self.schema['Para'].specialized_by()),
['Note'])
self.assertEqual(self.schema['Note'].specializes().type, 'Para')
self.mh.cmd_add_entity_type('Text')
- self.mh.repo.schema.rebuild_infered_relations()
self.assertEqual(sorted(et.type for et in self.schema['Para'].specialized_by()),
['Note', 'Text'])
self.assertEqual(self.schema['Text'].specializes().type, 'Para')
@@ -628,12 +618,8 @@
#
# also we need more tests about introducing/removing base classes or
# specialization relationship...
- self.session.data['rebuild-infered'] = True
- try:
- self.session.execute('DELETE X specializes Y WHERE Y name "Para"')
- self.session.commit(free_cnxset=False)
- finally:
- self.session.data['rebuild-infered'] = False
+ self.session.execute('DELETE X specializes Y WHERE Y name "Para"')
+ self.session.commit(free_cnxset=False)
self.assertEqual(sorted(et.type for et in self.schema['Para'].specialized_by()),
[])
self.assertEqual(self.schema['Note'].specializes(), None)