server/schemahooks.py
branchstable
changeset 3526 dfb2ebb765e2
parent 2967 e7d348134006
child 3531 c095f5f54873
--- a/server/schemahooks.py	Tue Sep 29 15:10:12 2009 -0700
+++ b/server/schemahooks.py	Wed Sep 30 16:05:43 2009 +0200
@@ -307,10 +307,11 @@
         default = entity.defaultval
         if default is not None:
             default = TYPE_CONVERTER[entity.otype.name](default)
-        rdef = self.init_rdef(default=default,
-                              indexed=entity.indexed,
-                              fulltextindexed=entity.fulltextindexed,
-                              internationalizable=entity.internationalizable)
+        props = {'default': default,
+                 'indexed': entity.indexed,
+                 'fulltextindexed': entity.fulltextindexed,
+                 'internationalizable': entity.internationalizable}
+        rdef = self.init_rdef(**props)
         sysource = session.pool.source('system')
         attrtype = type_from_constraints(sysource.dbhelper, rdef.object,
                                          rdef.constraints)
@@ -343,6 +344,20 @@
             except Exception, ex:
                 self.error('error while creating index for %s.%s: %s',
                            table, column, ex)
+        # final relations are not infered, propagate
+        rschema = self.schema.rschema(rdef.name)
+        eschema = self.schema.eschema(rdef.subject)
+        props.update({'constraints': rdef.constraints,
+                      'description': rdef.description,
+                      'cardinality': rdef.cardinality,
+                      'constraints': rdef.constraints,
+                      'order': rdef.order})
+        for specialization in eschema.specialized_by(False):
+            if rschema.has_rdef(specialization, rdef.object):
+                continue
+            for rql, args in ss.frdef2rql(rschema, str(specialization),
+                                          rdef.object, props):
+                session.execute(rql, args)
 
 
 class SourceDbCWRelationAdd(SourceDbCWAttributeAdd):