hooks/syncschema.py
changeset 3536 f6c9a5df80fb
parent 3531 c095f5f54873
parent 3431 6944a92c16f2
child 3589 a5432f99f2d9
--- a/hooks/syncschema.py	Tue Sep 29 15:58:44 2009 +0200
+++ b/hooks/syncschema.py	Wed Sep 30 18:57:42 2009 +0200
@@ -317,10 +317,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)
@@ -353,6 +354,23 @@
             except Exception, ex:
                 self.error('error while creating index for %s.%s: %s',
                            table, column, ex)
+        # final relations are not infered, propagate
+        try:
+            eschema = self.schema.eschema(rdef.subject)
+        except KeyError:
+            return # entity type currently being added
+        rschema = self.schema.rschema(rdef.name)
+        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):