hooks/syncschema.py
changeset 8216 99ff746e8de8
parent 8190 2a3c1b787688
parent 8215 4b32678c21a7
child 8533 73469aa94afe
equal deleted inserted replaced
8214:ce9556358dbd 8216:99ff746e8de8
   266         cmap = ss.cstrtype_mapping(session)
   266         cmap = ss.cstrtype_mapping(session)
   267         for rtype in (META_RTYPES - VIRTUAL_RTYPES):
   267         for rtype in (META_RTYPES - VIRTUAL_RTYPES):
   268             try:
   268             try:
   269                 rschema = schema[rtype]
   269                 rschema = schema[rtype]
   270             except KeyError:
   270             except KeyError:
   271                 if rtype == 'cw_source':
   271                 self.critical('rtype %s was not handled at cwetype creation time', rtype)
   272                     continue # XXX 3.10 migration
   272                 continue
   273                 raise
       
   274             sampletype = rschema.subjects()[0]
   273             sampletype = rschema.subjects()[0]
   275             desttype = rschema.objects()[0]
   274             desttype = rschema.objects()[0]
   276             rdef = copy(rschema.rdef(sampletype, desttype))
   275             rdef = copy(rschema.rdef(sampletype, desttype))
   277             rdef.subject = _MockEntity(eid=entity.eid)
   276             rdef.subject = _MockEntity(eid=entity.eid)
   278             mock = _MockEntity(eid=None)
   277             mock = _MockEntity(eid=None)
   491                 # XXX may may want to use creation_date
   490                 # XXX may may want to use creation_date
   492                 if default == 'TODAY':
   491                 if default == 'TODAY':
   493                     default = syssource.dbhelper.sql_current_date()
   492                     default = syssource.dbhelper.sql_current_date()
   494                 elif default == 'NOW':
   493                 elif default == 'NOW':
   495                     default = syssource.dbhelper.sql_current_timestamp()
   494                     default = syssource.dbhelper.sql_current_timestamp()
   496                 session.system_sql('UPDATE %s SET %s=%(default)s'
   495                 session.system_sql('UPDATE %s SET %s=%s'
   497                                    % (table, column, default))
   496                                    % (table, column, default))
   498             else:
   497             else:
   499                 session.system_sql('UPDATE %s SET %s=%%(default)s' % (table, column),
   498                 session.system_sql('UPDATE %s SET %s=%%(default)s' % (table, column),
   500                                    {'default': default})
   499                                    {'default': default})
   501 
   500