Пример #1
0
        /// <summary>
        /// Gets the differences between this item and another of the same type
        /// </summary>
        /// <param name="other">Another item of the same type</param>
        /// <param name="allDifferences">if set to <c>true</c> collects all differences,
        /// otherwise only the first difference is collected.</param>
        /// <returns>
        /// A Difference if there are differences between the items, otherwise null
        /// </returns>
        public override Difference GetDifferences(Item other, bool allDifferences)
        {
            FulltextColumn otherColumn = other as FulltextColumn;

            if (otherColumn == null)
            {
                return(new Difference(DifferenceType.Created, Name));
            }

            Difference difference = new Difference(DifferenceType.Modified, Name);

            if (Name != otherColumn.Name)
            {
                difference.AddMessage("Name", otherColumn.Name, Name);
                if (!allDifferences)
                {
                    return(difference);
                }
            }
            if (Language != otherColumn.Language)
            {
                difference.AddMessage("Language", otherColumn.Language, Language);
                if (!allDifferences)
                {
                    return(difference);
                }
            }

            return(difference.Messages.Count > 0 ? difference : null);
        }
Пример #2
0
        /// <summary>
        /// Gets the differences between this item and another of the same type
        /// </summary>
        /// <param name="other">Another item of the same type</param>
        /// <param name="allDifferences">if set to <c>true</c> collects all differences,
        /// otherwise only the first difference is collected.</param>
        /// <returns>
        /// A Difference if there are differences between the items, otherwise null
        /// </returns>
        public override Difference GetDifferences(Item other, bool allDifferences)
        {
            UnparsedItem otherItem = other as UnparsedItem;

            if (otherItem == null || this.GetType() != other.GetType())
            {
                return(new Difference(DifferenceType.Created, Name));
            }

            Difference difference = new Difference(DifferenceType.Modified, Name);

            if (Name != otherItem.Name)
            {
                difference.AddMessage("Name", otherItem.Name, Name);
                if (!allDifferences)
                {
                    return(difference);
                }
            }
            if (Body != otherItem.Body &&
                Body.Replace("[", "").Replace("]", "") != otherItem.Body.Replace("[", "").Replace("]", ""))
            {
                difference.AddMessage("Body is different");
                if (!allDifferences)
                {
                    return(difference);
                }
            }

            return(difference.Messages.Count > 0 ? difference : null);
        }
Пример #3
0
        /// <summary>
        /// Gets the differences between this item and another of the same type
        /// </summary>
        /// <param name="other">Another item of the same type</param>
        /// <param name="allDifferences">if set to <c>true</c> collects all differences,
        /// otherwise only the first difference is collected.</param>
        /// <returns>
        /// A Difference if there are differences between the items, otherwise null
        /// </returns>
        public override Difference GetDifferences(Item other, bool allDifferences)
        {
            FulltextCatalog otherCatalog = other as FulltextCatalog;

            if (otherCatalog == null)
            {
                return(new Difference(DifferenceType.Created, Name));
            }

            Difference difference = new Difference(DifferenceType.Modified, Name);

            if (Name != otherCatalog.Name)
            {
                difference.AddMessage("Name", otherCatalog.Name, Name);
                if (!allDifferences)
                {
                    return(difference);
                }
            }

            if (AccentSensitivity != null && otherCatalog.AccentSensitivity != null &&
                AccentSensitivity != otherCatalog.AccentSensitivity)
            {
                difference.AddMessage("Accent Sensitivity", otherCatalog.AccentSensitivity, AccentSensitivity);
                if (!allDifferences)
                {
                    return(difference);
                }
            }

            if (Authorization != null && otherCatalog.Authorization != null &&
                Authorization != otherCatalog.Authorization)
            {
                difference.AddMessage("Authorization", otherCatalog.Authorization, Authorization);
                if (!allDifferences)
                {
                    return(difference);
                }
            }

            if (Default != otherCatalog.Default)
            {
                difference.AddMessage("Default", otherCatalog.Default, Default);
                if (!allDifferences)
                {
                    return(difference);
                }
            }

            return(difference.Messages.Count > 0 ? difference : null);
        }
Пример #4
0
        private Difference GetColumnDifferences(Constraint otherConstraint, bool allDifferences, Difference difference)
        {
            if (Columns.Count != otherConstraint.Columns.Count)
            {
                difference.AddMessage("Column Count", otherConstraint.Columns.Count, Columns.Count);
                if (!allDifferences)
                {
                    return(difference);
                }
            }
            else
            {
                for (int i = 0; i < Columns.Count; i++)
                {
                    if (Columns[i] != otherConstraint.Columns[i])
                    {
                        difference.AddMessage("Column Difference", otherConstraint.Columns[i], Columns[i]);
                        if (!allDifferences)
                        {
                            return(difference);
                        }
                    }
                }
            }

            if (ReferencedColumns.Count != otherConstraint.ReferencedColumns.Count)
            {
                difference.AddMessage("Referenced column count", otherConstraint.ReferencedColumns.Count, ReferencedColumns.Count);
                if (!allDifferences)
                {
                    return(difference);
                }
            }
            else
            {
                for (int i = 0; i < ReferencedColumns.Count; i++)
                {
                    if (ReferencedColumns[i] != otherConstraint.ReferencedColumns[i])
                    {
                        difference.AddMessage("Column Difference", otherConstraint.ReferencedColumns[i], ReferencedColumns[i]);
                        if (!allDifferences)
                        {
                            return(difference);
                        }
                    }
                }
            }

            return(difference.Messages.Count > 0 ? difference : null);
        }
Пример #5
0
        /// <summary>
        /// Gets the differences between this item and another of the same type
        /// </summary>
        /// <param name="other">Another item of the same type</param>
        /// <param name="allDifferences">if set to <c>true</c> collects all differences,
        /// otherwise only the first difference is collected.</param>
        /// <returns>
        /// A Difference if there are differences between the items, otherwise null
        /// </returns>
        public override Difference GetDifferences(Item other, bool allDifferences)
        {
            TriggerOrder otherOrder = other as TriggerOrder;

            if (otherOrder == null)
            {
                return(new Difference(DifferenceType.Created, Name));
            }

            Difference difference = new Difference(DifferenceType.Modified, Name);

            if (Order != otherOrder.Order)
            {
                difference.AddMessage("Order", otherOrder.Order, Order);
                if (!allDifferences)
                {
                    return(difference);
                }
            }
            if (StatementType != otherOrder.StatementType)
            {
                difference.AddMessage("Statement Type", otherOrder.StatementType, StatementType);
                if (!allDifferences)
                {
                    return(difference);
                }
            }
            if (Trigger != otherOrder.Trigger)
            {
                difference.AddMessage("Trigger", otherOrder.Trigger, Trigger);
                if (!allDifferences)
                {
                    return(difference);
                }
            }

            return(difference.Messages.Count > 0 ? difference : null);
        }
Пример #6
0
        /// <summary>
        /// Gets the differences between this item and another of the same type
        /// </summary>
        /// <param name="other">Another item of the same type</param>
        /// <param name="allDifferences">if set to <c>true</c> collects all differences,
        /// otherwise only the first difference is collected.</param>
        /// <returns>
        /// A Difference if there are differences between the items, otherwise null
        /// </returns>
        public override Difference GetDifferences(Item other, bool allDifferences)
        {
            FulltextIndex otherIndex = other as FulltextIndex;

            if (otherIndex == null)
            {
                return(new Difference(DifferenceType.Created, Name));
            }

            Difference difference = new Difference(DifferenceType.Modified, Name);

            if (Name != otherIndex.Name)
            {
                difference.AddMessage("Name", otherIndex.Name, Name);
                if (!allDifferences)
                {
                    return(difference);
                }
            }
            if (Table != otherIndex.Table)
            {
                difference.AddMessage("Table", otherIndex.Table, Table);
                if (!allDifferences)
                {
                    return(difference);
                }
            }
            if (ChangeTracking != otherIndex.ChangeTracking)
            {
                difference.AddMessage("Change Tracking", otherIndex.ChangeTracking, ChangeTracking);
                if (!allDifferences)
                {
                    return(difference);
                }
            }
            if (FulltextCatalog != otherIndex.FulltextCatalog && FulltextCatalog != "" && otherIndex.FulltextCatalog != "")
            {
                difference.AddMessage("Fulltext Catalog", otherIndex.FulltextCatalog, FulltextCatalog);
                if (!allDifferences)
                {
                    return(difference);
                }
            }
            if (FulltextFilegroup != otherIndex.FulltextFilegroup && FulltextFilegroup != "" && otherIndex.FulltextFilegroup != "")
            {
                difference.AddMessage("Fulltext Filegroup", otherIndex.FulltextFilegroup, FulltextFilegroup);
                if (!allDifferences)
                {
                    return(difference);
                }
            }
            if (KeyIndex != otherIndex.KeyIndex)
            {
                difference.AddMessage("Key Index", otherIndex.KeyIndex, KeyIndex);
                if (!allDifferences)
                {
                    return(difference);
                }
            }
            if (!EqualWithDefault(StopList, otherIndex.StopList, "system"))
            {
                difference.AddMessage("Stoplist", otherIndex.StopList, StopList);
                if (!allDifferences)
                {
                    return(difference);
                }
            }

            if (Columns.Count != otherIndex.Columns.Count)
            {
                difference.AddMessage("Column Count", otherIndex.Columns.Count, Columns.Count);
                if (!allDifferences)
                {
                    return(difference);
                }
            }
            else
            {
                //Order is not important for fulltext indexes
                Columns.Sort();
                otherIndex.Columns.Sort();
                for (int i = 0; i < Columns.Count; i++)
                {
                    Difference columnDifference = Columns[i].GetDifferences(otherIndex.Columns[i], allDifferences);
                    if (columnDifference != null)
                    {
                        difference.AddMessage(columnDifference);
                        if (!allDifferences)
                        {
                            return(difference);
                        }
                    }
                }
            }

            return(difference.Messages.Count > 0 ? difference : null);
        }
Пример #7
0
        /// <summary>
        /// Gets the differences between this item and another of the same type
        /// </summary>
        /// <param name="other">Another item of the same type</param>
        /// <param name="allDifferences">if set to <c>true</c> collects all differences,
        /// otherwise only the first difference is collected.</param>
        /// <returns>
        /// A Difference if there are differences between the items, otherwise null
        /// </returns>
        public override Difference GetDifferences(Item other, bool allDifferences)
        {
            Table otherTable = other as Table;

            if (otherTable == null)
            {
                return(new Difference(DifferenceType.Created, Name));
            }

            Difference difference = new Difference(DifferenceType.Modified, Name);

            if (Name != otherTable.Name)
            {
                difference.AddMessage("Name", otherTable.Name, Name);
                if (!allDifferences)
                {
                    return(difference);
                }
            }
            if (FileGroup != null && FileGroup != otherTable.FileGroup &&
                !PrimaryFileGroups(FileGroup, otherTable.FileGroup))
            {
                difference.AddMessage("File group", otherTable.FileGroup, FileGroup);
                if (!allDifferences)
                {
                    return(difference);
                }
            }
            if (TextFileGroup != null && TextFileGroup != otherTable.TextFileGroup &&
                !PrimaryFileGroups(TextFileGroup, otherTable.TextFileGroup))
            {
                difference.AddMessage("Text File Group",
                                      otherTable.TextFileGroup == null ? "none" : (string)otherTable.TextFileGroup,
                                      TextFileGroup);
                if (!allDifferences)
                {
                    return(difference);
                }
            }

            if (Columns.Count != otherTable.Columns.Count)
            {
                difference.AddMessage("Column Count", otherTable.Columns.Count, Columns.Count);
                if (!allDifferences)
                {
                    return(difference);
                }
            }
            else
            {
                for (int i = 0; i < Columns.Count; i++)
                {
                    Difference columnDifference = Columns[i].GetDifferences(otherTable.Columns[i], allDifferences);
                    if (columnDifference != null)
                    {
                        difference.AddMessage(columnDifference);
                        if (!allDifferences)
                        {
                            return(difference);
                        }
                    }
                }
            }

            return(difference.Messages.Count > 0 ? difference : null);
        }
Пример #8
0
        /// <summary>
        /// Gets the differences between this item and another of the same type
        /// </summary>
        /// <param name="other">Another item of the same type</param>
        /// <param name="allDifferences">if set to <c>true</c> collects all differences,
        /// otherwise only the first difference is collected.</param>
        /// <returns>
        /// A Difference if there are differences between the items, otherwise null
        /// </returns>
        public override Difference GetDifferences(Item other, bool allDifferences)
        {
            Index otherIndex = other as Index;

            if (otherIndex == null)
            {
                return(new Difference(DifferenceType.Created, Name));
            }

            Difference difference = new Difference(DifferenceType.Modified, Name);

            if (Name != otherIndex.Name)
            {
                difference.AddMessage("Name", otherIndex.Name, Name);
                if (!allDifferences)
                {
                    return(difference);
                }
            }
            if (Clustered != otherIndex.Clustered)
            {
                difference.AddMessage("Clustered", otherIndex.Clustered, Clustered);
                if (!allDifferences)
                {
                    return(difference);
                }
            }
            if (Enabled != otherIndex.Enabled)
            {
                difference.AddMessage("Enabled", otherIndex.Enabled, Enabled);
                if (!allDifferences)
                {
                    return(difference);
                }
            }
            if (FileGroup != null && FileGroup != otherIndex.FileGroup &&
                !PrimaryFileGroups(FileGroup, otherIndex.FileGroup))
            {
                difference.AddMessage("File group", otherIndex.FileGroup, FileGroup);
                if (!allDifferences)
                {
                    return(difference);
                }
            }
            if (Table != otherIndex.Table)
            {
                difference.AddMessage("Table", otherIndex.Table, Table);
                if (!allDifferences)
                {
                    return(difference);
                }
            }
            if (Unique != otherIndex.Unique)
            {
                difference.AddMessage("Unique", otherIndex.Unique, Unique);
                if (!allDifferences)
                {
                    return(difference);
                }
            }

            if (Columns.Count != otherIndex.Columns.Count)
            {
                difference.AddMessage("Column Count", otherIndex.Columns.Count, Columns.Count);
                if (!allDifferences)
                {
                    return(difference);
                }
            }
            else
            {
                for (int i = 0; i < Columns.Count; i++)
                {
                    if (Columns[i] != otherIndex.Columns[i])
                    {
                        difference.AddMessage("Column Difference", otherIndex.Columns[i], Columns[i]);
                        if (!allDifferences)
                        {
                            return(difference);
                        }
                    }
                    if (ColumnDirections[i] != otherIndex.ColumnDirections[i])
                    {
                        difference.AddMessage("Column Direction Difference",
                                              otherIndex.Columns[i] + " (" + otherIndex.ColumnDirections[i] + ")",
                                              Columns[i] + " (" + ColumnDirections[i] + ")");
                        if (!allDifferences)
                        {
                            return(difference);
                        }
                    }
                }
            }

            if (Include.Count != otherIndex.Include.Count)
            {
                difference.AddMessage("Include Count", otherIndex.Include.Count, Include.Count);
                if (!allDifferences)
                {
                    return(difference);
                }
            }
            else
            {
                for (int i = 0; i < Include.Count; i++)
                {
                    if (Include[i] != otherIndex.Include[i])
                    {
                        difference.AddMessage("Include Difference", otherIndex.Include[i], Include[i]);
                        if (!allDifferences)
                        {
                            return(difference);
                        }
                    }
                }
            }

            return(difference.Messages.Count > 0 ? difference : null);
        }
Пример #9
0
        /// <summary>
        /// Gets the differences between this item and another of the same type
        /// </summary>
        /// <param name="other">Another item of the same type</param>
        /// <param name="allDifferences">if set to <c>true</c> collects all differences,
        /// otherwise only the first difference is collected.</param>
        /// <returns>
        /// A Difference if there are differences between the items, otherwise null
        /// </returns>
        public override Difference GetDifferences(Item other, bool allDifferences)
        {
            Constraint otherConstraint = other as Constraint;

            if (otherConstraint == null)
            {
                return(new Difference(DifferenceType.Created, Name));
            }

            Difference difference = new Difference(DifferenceType.Modified, Name);

            if (Name != otherConstraint.Name)
            {
                difference.AddMessage("Name", otherConstraint.Name.Object, Name.Object);
                if (!allDifferences)
                {
                    return(difference);
                }
            }
            if (Clustered != otherConstraint.Clustered)
            {
                difference.AddMessage("Clustering", otherConstraint.Clustered, Clustered);
                if (!allDifferences)
                {
                    return(difference);
                }
            }
            if (Check != otherConstraint.Check)
            {
                difference.AddMessage("Check", otherConstraint.Check, Check);
                if (!allDifferences)
                {
                    return(difference);
                }
            }
            if (ConstrainedTable != otherConstraint.ConstrainedTable)
            {
                difference.AddMessage("Constrained table", otherConstraint.ConstrainedTable, ConstrainedTable);
                if (!allDifferences)
                {
                    return(difference);
                }
            }
            if ((DefaultValue == null ? null : DefaultValue.ToLower()) != (otherConstraint.DefaultValue == null ? null : otherConstraint.DefaultValue.ToLower()))
            {
                difference.AddMessage("Default Value", otherConstraint.DefaultValue, DefaultValue);
                if (!allDifferences)
                {
                    return(difference);
                }
            }
            if (Type != otherConstraint.Type)
            {
                difference.AddMessage("Type", otherConstraint.Type.ToString(), Type.ToString());
                if (!allDifferences)
                {
                    return(difference);
                }
            }
            if (NotForReplication != otherConstraint.NotForReplication)
            {
                difference.AddMessage("Not for replication", otherConstraint.NotForReplication, NotForReplication);
                if (!allDifferences)
                {
                    return(difference);
                }
            }

            return(GetColumnDifferences(otherConstraint, allDifferences, difference));
        }
Пример #10
0
        /// <summary>
        /// Gets the differences between this item and another of the same type
        /// </summary>
        /// <param name="other">Another item of the same type</param>
        /// <param name="allDifferences">if set to <c>true</c> collects all differences,
        /// otherwise only the first difference is collected.</param>
        /// <returns>
        /// A Difference if there are differences between the items, otherwise null
        /// </returns>
        public override Difference GetDifferences(Item other, bool allDifferences)
        {
            Column otherColumn = other as Column;

            if (otherColumn == null)
            {
                return(new Difference(DifferenceType.Created, Name));
            }

            Difference difference = new Difference(DifferenceType.Modified, Name);

            if (Name != otherColumn.Name)
            {
                difference.AddMessage("Name", otherColumn.Name, Name);
                if (!allDifferences)
                {
                    return(difference);
                }
            }
            if (As != otherColumn.As)
            {
                difference.AddMessage("Computed column expression", otherColumn.As, As);
                if (!allDifferences)
                {
                    return(difference);
                }
            }
            if (Collate != otherColumn.Collate)
            {
                //deal with default collation
                string collate0 = Collate == null ? DEFAULT_COLLATION : Collate;
                string collate1 = otherColumn.Collate == null ? DEFAULT_COLLATION : otherColumn.Collate;
                if (collate0 != collate1)
                {
                    difference.AddMessage("Collation", collate1, collate0);
                    if (!allDifferences)
                    {
                        return(difference);
                    }
                }
            }
            if (Identity != otherColumn.Identity)
            {
                difference.AddMessage("Identity", otherColumn.Identity, Identity);
                if (!allDifferences)
                {
                    return(difference);
                }
            }
            if (IdentityIncrement != otherColumn.IdentityIncrement)
            {
                difference.AddMessage("Identity increment", otherColumn.IdentityIncrement, IdentityIncrement);
                if (!allDifferences)
                {
                    return(difference);
                }
            }
            if (IdentityReplication != otherColumn.IdentityReplication)
            {
                difference.AddMessage("Identity replication", otherColumn.IdentityReplication, IdentityReplication);
                if (!allDifferences)
                {
                    return(difference);
                }
            }
            if (IdentitySeed != otherColumn.IdentitySeed)
            {
                difference.AddMessage("Identity seed", otherColumn.IdentitySeed, IdentitySeed);
                if (!allDifferences)
                {
                    return(difference);
                }
            }
            if (Nullable != otherColumn.Nullable)
            {
                difference.AddMessage("Nullability", otherColumn.Nullable, Nullable);
                if (!allDifferences)
                {
                    return(difference);
                }
            }
            if ((Size ?? "").ToLower() != (otherColumn.Size ?? "").ToLower())
            {
                difference.AddMessage("Size", otherColumn.Size, Size);
                if (!allDifferences)
                {
                    return(difference);
                }
            }
            if (Type != otherColumn.Type)
            {
                difference.AddMessage("Type", otherColumn.Type, Type);
                if (!allDifferences)
                {
                    return(difference);
                }
            }

            return(difference.Messages.Count > 0 ? difference : null);
        }