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)' % |