hooks/syncschema.py
changeset 10671 e08102f45237
parent 10666 7f6b5f023884
child 10799 ec97974b9010
equal deleted inserted replaced
10670:96380c1524b0 10671:e08102f45237
   767         elif cstrtype == 'UniqueConstraint' and oldcstr is None:
   767         elif cstrtype == 'UniqueConstraint' and oldcstr is None:
   768             syssource.update_rdef_unique(cnx, rdef)
   768             syssource.update_rdef_unique(cnx, rdef)
   769             self.unique_changed = True
   769             self.unique_changed = True
   770         if cstrtype in ('BoundaryConstraint', 'IntervalBoundConstraint', 'StaticVocabularyConstraint'):
   770         if cstrtype in ('BoundaryConstraint', 'IntervalBoundConstraint', 'StaticVocabularyConstraint'):
   771             if oldcstr is not None:
   771             if oldcstr is not None:
   772                 oldcstrname = 'cstr' + md5(rdef.subject.type + rdef.rtype.type + cstrtype +
   772                 oldcstrname = 'cstr' + md5((rdef.subject.type + rdef.rtype.type + cstrtype +
   773                                            (self.oldcstr.serialize() or '')).hexdigest()
   773                                             (self.oldcstr.serialize() or '')).encode('ascii')).hexdigest()
   774                 cnx.system_sql('ALTER TABLE %s%s DROP CONSTRAINT %s' %
   774                 cnx.system_sql('ALTER TABLE %s%s DROP CONSTRAINT %s' %
   775                                (SQL_PREFIX, rdef.subject.type, oldcstrname))
   775                                (SQL_PREFIX, rdef.subject.type, oldcstrname))
   776             cstrname, check = y2sql.check_constraint(rdef.subject, rdef.object, rdef.rtype.type,
   776             cstrname, check = y2sql.check_constraint(rdef.subject, rdef.object, rdef.rtype.type,
   777                     newcstr, syssource.dbhelper, prefix=SQL_PREFIX)
   777                     newcstr, syssource.dbhelper, prefix=SQL_PREFIX)
   778             cnx.system_sql('ALTER TABLE %s%s ADD CONSTRAINT %s CHECK(%s)' %
   778             cnx.system_sql('ALTER TABLE %s%s ADD CONSTRAINT %s CHECK(%s)' %