[migration] consider extra_props in rdef created during attribute creation hook
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 09 Dec 2015 17:44:17 +0100
changeset 11004 14ba505fb652
parent 11003 53820b08a723
child 11005 f8417bd135ed
[migration] consider extra_props in rdef created during attribute creation hook else we may miss important data such as type parametrization (see postgis.Geometry for instance). Related to #7569998
hooks/syncschema.py
server/test/unittest_migractions.py
--- a/hooks/syncschema.py	Wed Dec 09 17:44:17 2015 +0100
+++ b/hooks/syncschema.py	Wed Dec 09 17:44:17 2015 +0100
@@ -26,8 +26,10 @@
 __docformat__ = "restructuredtext en"
 from cubicweb import _
 
+import json
 from copy import copy
 from hashlib import md5
+
 from yams.schema import (BASE_TYPES, BadSchemaDefinition,
                          RelationSchema, RelationDefinitionSchema)
 from yams import buildobjs as ybo, convert_default_value
@@ -457,6 +459,8 @@
                  'indexed': entity.indexed,
                  'fulltextindexed': entity.fulltextindexed,
                  'internationalizable': entity.internationalizable}
+        if entity.extra_props:
+            props.update(json.load(entity.extra_props))
         # entity.formula may not exist yet if we're migrating to 3.20
         if hasattr(entity, 'formula'):
             props['formula'] = entity.formula
--- a/server/test/unittest_migractions.py	Wed Dec 09 17:44:17 2015 +0100
+++ b/server/test/unittest_migractions.py	Wed Dec 09 17:44:17 2015 +0100
@@ -294,6 +294,10 @@
             mh.cmd_add_cube('fakegis')
             self.assertIn('Geometry', self.schema)
             self.assertTrue(self.schema['Geometry'].final)
+            rdef = self.schema['geometry'].rdefs[('Location', 'Geometry')]
+            self.assertEqual(rdef.geom_type, 'GEOMETRYCOLLECTION')
+            self.assertEqual(rdef.coord_dimension, 2)
+            self.assertEqual(rdef.srid, 4326)
 
     def test_add_drop_entity_type(self):
         with self.mh() as (cnx, mh):