Esempio n. 1
0
 public static bool EqualsConstraints(ConstraintInfo csrc, ConstraintInfo cdst, DbDiffOptions options, bool checkNames, DbObjectPairing pairing)
 {
     if (checkNames && !options.IgnoreConstraintNames)
     {
         if (!EqualNames(csrc.ConstraintName, cdst.ConstraintName, options))
         {
             return false;
             //if (csrc is PrimaryKeyInfo && cdst is PrimaryKeyInfo) // && (pairing.Source.Dialect.DialectCaps.AnonymousPrimaryKey || pairing.Target.Dialect.DialectCaps.AnonymousPrimaryKey))
             //{
             //    // do nothing
             //}
             //else
             //{
             //    return false;
             //}
         }
     }
     if (csrc.GetType() != cdst.GetType()) return false;
     if (csrc is ColumnsConstraintInfo)
     {
         TableInfo tsrc = pairing.Source.FindTable(csrc.OwnerTable.FullName);
         TableInfo tdst = pairing.Target.FindTable(cdst.OwnerTable.FullName);
         if (!EqualsColumnRefs(tsrc, tdst, ((ColumnsConstraintInfo)csrc).Columns, ((ColumnsConstraintInfo)cdst).Columns)) return false;
         //if (!((ColumnsConstraint)csrc).Columns.EqualSequence(((ColumnsConstraint)cdst).Columns)) return false;
         if (csrc is ForeignKeyInfo)
         {
             var fsrc = (ForeignKeyInfo)csrc;
             var fdst = (ForeignKeyInfo)cdst;
             if (!EqualFullNames(fsrc.RefTableFullName, fdst.RefTableFullName, options)) return false;
             TableInfo psrc = pairing.Source.FindTable(fsrc.RefTableFullName);
             TableInfo pdst = pairing.Target.FindTable(fdst.RefTableFullName);
             if (!EqualsColumnRefs(psrc, pdst, fsrc.RefColumns, fdst.RefColumns)) return false;
             if (fsrc.OnDeleteAction != fdst.OnDeleteAction) return false;
             if (fsrc.OnUpdateAction != fdst.OnUpdateAction) return false;
         }
         //if (csrc is IIndex)
         //{
         //    var isrc = (IndexConstraint)csrc;
         //    var idst = (IndexConstraint)cdst;
         //    if (isrc.IsUnique != idst.IsUnique) return false;
         //}
     }
     //if (csrc is CheckConstraint)
     //{
     //    if (((CheckConstraint)csrc).Expression != ((CheckConstraint)cdst).Expression) return false;
     //}
     return true;
 }
Esempio n. 2
0
 private static int CompareConstraints(ConstraintInfo lft, ConstraintInfo rgt)
 {
     var nl = lft.ConstraintName;
     var nr = rgt.ConstraintName;
     if (lft.GetType() != rgt.GetType()) return String.Compare(lft.GetType().FullName, rgt.GetType().FullName);
     if (nl != null && nr != null) return String.Compare(nl, nr);
     return 0;
 }