Skip to content

Commit

Permalink
Remove SystemTypeId property in the columns and the user type.
Browse files Browse the repository at this point in the history
  • Loading branch information
GillesTourreau committed Sep 25, 2024
1 parent f544ac2 commit 194590f
Show file tree
Hide file tree
Showing 9 changed files with 3 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ public static IList<SqlTableDifferences> Compare(IReadOnlyList<SqlTable> source,
return this.CreateDifferences(
column,
this.CompareProperty(column, t => t.Position, nameof(column.Position)),
this.CompareProperty(column, t => t.SystemTypeId, nameof(column.SystemTypeId)),
this.CompareProperty(column, t => t.MaxLength, nameof(column.MaxLength)),
this.CompareProperty(column, t => t.Precision, nameof(column.Precision)),
this.CompareProperty(column, t => t.Scale, nameof(column.Scale)),
Expand Down Expand Up @@ -253,8 +252,7 @@ public static IList<SqlTableDifferences> Compare(IReadOnlyList<SqlTable> source,
userType,
this.CompareProperty(userType, ut => ut.IsNullable, nameof(userType.IsNullable)),
this.CompareProperty(userType, ut => ut.IsTableType, nameof(userType.IsTableType)),
this.CompareProperty(userType, ut => ut.MaxLength, nameof(userType.MaxLength)),
this.CompareProperty(userType, ut => ut.SystemTypeId, nameof(userType.SystemTypeId)));
this.CompareProperty(userType, ut => ut.MaxLength, nameof(userType.MaxLength)));
}

public SqlObjectDifferences? Visit(SqlView view)
Expand Down
5 changes: 0 additions & 5 deletions src/UnitTests.Databases.SqlServer/ObjectModel/SqlColumn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ internal SqlColumn()
/// </summary>
public required int Position { get; init; }

/// <summary>
/// Gets the system type identifier of the column.
/// </summary>
public required byte SystemTypeId { get; init; }

/// <summary>
/// Gets the type name of the column.
/// </summary>
Expand Down
5 changes: 0 additions & 5 deletions src/UnitTests.Databases.SqlServer/ObjectModel/SqlUserType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ internal SqlUserType()
/// </summary>
public required string Name { get; init; }

/// <summary>
/// Gets the system type identifier which is based the user type.
/// </summary>
public required byte SystemTypeId { get; init; }

/// <summary>
/// Gets the max length of the type.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ public static async Task<IReadOnlyList<SqlUserType>> GetUserTypesAsync(this SqlS
const string sql = @"
SELECT
[t].[name] AS [Name],
[t].[system_type_id] AS [SystemTypeId],
[t].[max_length] AS [MaxLength],
[t].[is_nullable] AS [IsNullable],
[t].[is_table_type] AS [IsTableType]
Expand Down Expand Up @@ -286,7 +285,6 @@ private static async Task<ILookup<int, DataRow>> GetColumnsAsync(SqlServerDataba
[t].[object_id] AS [TableId],
[c].[name] AS [Name],
ROW_NUMBER() OVER(PARTITION BY [t].[name] ORDER BY [t].[name], [c].[column_id]) AS [Position],
[c].[system_type_id] AS [SystemTypeId],
[ty].[name] AS [TypeName],
[c].[max_length] AS [MaxLength],
[c].[precision] AS [Precision],
Expand Down Expand Up @@ -486,7 +484,6 @@ private static SqlColumn ToColumn(DataRow row)
Precision = (byte)row["Precision"],
Position = Convert.ToInt32(row["Position"], CultureInfo.InvariantCulture),
Scale = (byte)row["Scale"],
SystemTypeId = (byte)row["SystemTypeId"],
TypeName = (string)row["TypeName"],
};
}
Expand Down Expand Up @@ -592,7 +589,6 @@ private static SqlUserType ToUserType(DataRow row)
IsTableType = (bool)row["IsTableType"],
Name = (string)row["Name"],
MaxLength = (short)row["MaxLength"],
SystemTypeId = (byte)row["SystemTypeId"],
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public void ToStringTest()
IsTableType = default,
MaxLength = default,
Name = "The source",
SystemTypeId = default,
};

var target = new SqlUserType()
Expand All @@ -26,7 +25,6 @@ public void ToStringTest()
IsTableType = default,
MaxLength = default,
Name = "The source",
SystemTypeId = default,
};

var properties = new[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public void ToStringTest()
Position = default,
Precision = default,
Scale = default,
SystemTypeId = default,
TypeName = default,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public void ToStringTest()
IsNullable = default,
IsTableType = default,
MaxLength = default,
SystemTypeId = default
};

userType.ToString().Should().Be("The name");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@

------ Columns ------
- Type
* SystemTypeId:
Source: 56
Target: 167
* MaxLength:
Source: 4
Target: 50
Expand Down Expand Up @@ -182,9 +179,6 @@
* MaxLength:
Source: 11
Target: 4
* SystemTypeId:
Source: 167
Target: 56
- TypeTarget (Missing in the source)
- TypeSource (Missing in the target)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ public async Task CompareAsync()
differences.Tables[0].Source.Columns[0].Position.Should().Be(1);
differences.Tables[0].Source.Columns[0].Precision.Should().Be(10);
differences.Tables[0].Source.Columns[0].Scale.Should().Be(0);
differences.Tables[0].Source.Columns[0].SystemTypeId.Should().Be(56);
differences.Tables[0].Source.Columns[0].TypeName.Should().Be("int");

differences.Tables[0].Source.Columns[1].CollationName.Should().Be("SQL_Latin1_General_CP1_CI_AS");
Expand All @@ -92,7 +91,6 @@ public async Task CompareAsync()
differences.Tables[0].Source.Columns[1].Position.Should().Be(2);
differences.Tables[0].Source.Columns[1].Precision.Should().Be(0);
differences.Tables[0].Source.Columns[1].Scale.Should().Be(0);
differences.Tables[0].Source.Columns[1].SystemTypeId.Should().Be(167);
differences.Tables[0].Source.Columns[1].TypeName.Should().Be("varchar");

differences.Tables[0].Source.Columns[2].CollationName.Should().Be("SQL_Latin1_General_CP1_CI_AS");
Expand All @@ -105,7 +103,6 @@ public async Task CompareAsync()
differences.Tables[0].Source.Columns[2].Position.Should().Be(3);
differences.Tables[0].Source.Columns[2].Precision.Should().Be(0);
differences.Tables[0].Source.Columns[2].Scale.Should().Be(0);
differences.Tables[0].Source.Columns[2].SystemTypeId.Should().Be(167);
differences.Tables[0].Source.Columns[2].TypeName.Should().Be("varchar");

differences.Tables[0].Source.Columns[3].CollationName.Should().BeNull();
Expand All @@ -118,7 +115,6 @@ public async Task CompareAsync()
differences.Tables[0].Source.Columns[3].Position.Should().Be(4);
differences.Tables[0].Source.Columns[3].Precision.Should().Be(10);
differences.Tables[0].Source.Columns[3].Scale.Should().Be(2);
differences.Tables[0].Source.Columns[3].SystemTypeId.Should().Be(106);
differences.Tables[0].Source.Columns[3].TypeName.Should().Be("decimal");

differences.Tables[0].Source.Columns[4].CollationName.Should().BeNull();
Expand All @@ -131,7 +127,6 @@ public async Task CompareAsync()
differences.Tables[0].Source.Columns[4].Position.Should().Be(5);
differences.Tables[0].Source.Columns[4].Precision.Should().Be(10);
differences.Tables[0].Source.Columns[4].Scale.Should().Be(2);
differences.Tables[0].Source.Columns[4].SystemTypeId.Should().Be(106);
differences.Tables[0].Source.Columns[4].TypeName.Should().Be("decimal");

differences.Tables[0].Source.Columns[5].CollationName.Should().BeNull();
Expand All @@ -144,7 +139,6 @@ public async Task CompareAsync()
differences.Tables[0].Source.Columns[5].Position.Should().Be(6);
differences.Tables[0].Source.Columns[5].Precision.Should().Be(10);
differences.Tables[0].Source.Columns[5].Scale.Should().Be(0);
differences.Tables[0].Source.Columns[5].SystemTypeId.Should().Be(56);
differences.Tables[0].Source.Columns[5].TypeName.Should().Be("int");

differences.Tables[0].Source.Columns[6].CollationName.Should().BeNull();
Expand All @@ -157,7 +151,6 @@ public async Task CompareAsync()
differences.Tables[0].Source.Columns[6].Position.Should().Be(7);
differences.Tables[0].Source.Columns[6].Precision.Should().Be(10);
differences.Tables[0].Source.Columns[6].Scale.Should().Be(0);
differences.Tables[0].Source.Columns[6].SystemTypeId.Should().Be(56);
differences.Tables[0].Source.Columns[6].TypeName.Should().Be("int");

differences.Tables[0].Source.Columns[7].CollationName.Should().BeNull();
Expand All @@ -170,7 +163,6 @@ public async Task CompareAsync()
differences.Tables[0].Source.Columns[7].Position.Should().Be(8);
differences.Tables[0].Source.Columns[7].Precision.Should().Be(11);
differences.Tables[0].Source.Columns[7].Scale.Should().Be(2);
differences.Tables[0].Source.Columns[7].SystemTypeId.Should().Be(106);
differences.Tables[0].Source.Columns[7].TypeName.Should().Be("decimal");

differences.Tables[0].Source.Columns[8].CollationName.Should().BeNull();
Expand All @@ -183,7 +175,6 @@ public async Task CompareAsync()
differences.Tables[0].Source.Columns[8].Position.Should().Be(9);
differences.Tables[0].Source.Columns[8].Precision.Should().Be(10);
differences.Tables[0].Source.Columns[8].Scale.Should().Be(0);
differences.Tables[0].Source.Columns[8].SystemTypeId.Should().Be(56);
differences.Tables[0].Source.Columns[8].TypeName.Should().Be("int");

differences.Tables[0].Source.Columns[9].CollationName.Should().BeNull();
Expand All @@ -196,7 +187,6 @@ public async Task CompareAsync()
differences.Tables[0].Source.Columns[9].Position.Should().Be(10);
differences.Tables[0].Source.Columns[9].Precision.Should().Be(10);
differences.Tables[0].Source.Columns[9].Scale.Should().Be(0);
differences.Tables[0].Source.Columns[9].SystemTypeId.Should().Be(56);
differences.Tables[0].Source.Columns[9].TypeName.Should().Be("int");

differences.Tables[0].Target.Name.Should().Be("TableDifference");
Expand All @@ -214,7 +204,6 @@ public async Task CompareAsync()
differences.Tables[0].Target.Columns[0].Position.Should().Be(1);
differences.Tables[0].Target.Columns[0].Precision.Should().Be(0);
differences.Tables[0].Target.Columns[0].Scale.Should().Be(0);
differences.Tables[0].Target.Columns[0].SystemTypeId.Should().Be(167);
differences.Tables[0].Target.Columns[0].TypeName.Should().Be("varchar");

differences.Tables[0].Target.Columns[1].CollationName.Should().Be("SQL_Latin1_General_CP1_CI_AS");
Expand All @@ -227,7 +216,6 @@ public async Task CompareAsync()
differences.Tables[0].Target.Columns[1].Position.Should().Be(2);
differences.Tables[0].Target.Columns[1].Precision.Should().Be(0);
differences.Tables[0].Target.Columns[1].Scale.Should().Be(0);
differences.Tables[0].Target.Columns[1].SystemTypeId.Should().Be(167);
differences.Tables[0].Target.Columns[1].TypeName.Should().Be("varchar");

differences.Tables[0].Target.Columns[2].CollationName.Should().BeNull();
Expand All @@ -240,7 +228,6 @@ public async Task CompareAsync()
differences.Tables[0].Target.Columns[2].Position.Should().Be(3);
differences.Tables[0].Target.Columns[2].Precision.Should().Be(5);
differences.Tables[0].Target.Columns[2].Scale.Should().Be(2);
differences.Tables[0].Target.Columns[2].SystemTypeId.Should().Be(106);
differences.Tables[0].Target.Columns[2].TypeName.Should().Be("decimal");

differences.Tables[0].Target.Columns[3].CollationName.Should().Be("SQL_Latin1_General_CP1_CI_AS");
Expand All @@ -253,7 +240,6 @@ public async Task CompareAsync()
differences.Tables[0].Target.Columns[3].Position.Should().Be(4);
differences.Tables[0].Target.Columns[3].Precision.Should().Be(0);
differences.Tables[0].Target.Columns[3].Scale.Should().Be(0);
differences.Tables[0].Target.Columns[3].SystemTypeId.Should().Be(167);
differences.Tables[0].Target.Columns[3].TypeName.Should().Be("varchar");

differences.Tables[0].Target.Columns[4].CollationName.Should().BeNull();
Expand All @@ -266,7 +252,6 @@ public async Task CompareAsync()
differences.Tables[0].Target.Columns[4].Position.Should().Be(5);
differences.Tables[0].Target.Columns[4].Precision.Should().Be(10);
differences.Tables[0].Target.Columns[4].Scale.Should().Be(4);
differences.Tables[0].Target.Columns[4].SystemTypeId.Should().Be(106);
differences.Tables[0].Target.Columns[4].TypeName.Should().Be("decimal");

differences.Tables[0].Target.Columns[5].CollationName.Should().BeNull();
Expand All @@ -279,7 +264,6 @@ public async Task CompareAsync()
differences.Tables[0].Target.Columns[5].Position.Should().Be(6);
differences.Tables[0].Target.Columns[5].Precision.Should().Be(10);
differences.Tables[0].Target.Columns[5].Scale.Should().Be(0);
differences.Tables[0].Target.Columns[5].SystemTypeId.Should().Be(56);
differences.Tables[0].Target.Columns[5].TypeName.Should().Be("int");

differences.Tables[0].Target.Columns[6].CollationName.Should().BeNull();
Expand All @@ -292,7 +276,6 @@ public async Task CompareAsync()
differences.Tables[0].Target.Columns[6].Position.Should().Be(7);
differences.Tables[0].Target.Columns[6].Precision.Should().Be(10);
differences.Tables[0].Target.Columns[6].Scale.Should().Be(0);
differences.Tables[0].Target.Columns[6].SystemTypeId.Should().Be(56);
differences.Tables[0].Target.Columns[6].TypeName.Should().Be("int");

differences.Tables[0].Target.Columns[7].CollationName.Should().BeNull();
Expand All @@ -305,7 +288,6 @@ public async Task CompareAsync()
differences.Tables[0].Target.Columns[7].Position.Should().Be(8);
differences.Tables[0].Target.Columns[7].Precision.Should().Be(11);
differences.Tables[0].Target.Columns[7].Scale.Should().Be(4);
differences.Tables[0].Target.Columns[7].SystemTypeId.Should().Be(106);
differences.Tables[0].Target.Columns[7].TypeName.Should().Be("decimal");

differences.Tables[0].Target.Columns[8].CollationName.Should().BeNull();
Expand All @@ -318,7 +300,6 @@ public async Task CompareAsync()
differences.Tables[0].Target.Columns[8].Position.Should().Be(9);
differences.Tables[0].Target.Columns[8].Precision.Should().Be(10);
differences.Tables[0].Target.Columns[8].Scale.Should().Be(0);
differences.Tables[0].Target.Columns[8].SystemTypeId.Should().Be(56);
differences.Tables[0].Target.Columns[8].TypeName.Should().Be("int");

differences.Tables[0].Target.Columns[9].CollationName.Should().BeNull();
Expand All @@ -331,7 +312,6 @@ public async Task CompareAsync()
differences.Tables[0].Target.Columns[9].Position.Should().Be(10);
differences.Tables[0].Target.Columns[9].Precision.Should().Be(10);
differences.Tables[0].Target.Columns[9].Scale.Should().Be(0);
differences.Tables[0].Target.Columns[9].SystemTypeId.Should().Be(56);
differences.Tables[0].Target.Columns[9].TypeName.Should().Be("int");

differences.Tables[0].Columns.Should().HaveCount(9);
Expand Down Expand Up @@ -573,7 +553,6 @@ public async Task CompareAsync()
differences.Tables[1].Target.Columns[0].Position.Should().Be(1);
differences.Tables[1].Target.Columns[0].Precision.Should().Be(10);
differences.Tables[1].Target.Columns[0].Scale.Should().Be(0);
differences.Tables[1].Target.Columns[0].SystemTypeId.Should().Be(56);
differences.Tables[1].Target.Columns[0].TypeName.Should().Be("int");
differences.Tables[1].Target.ForeignKeys.Should().HaveCount(1);
differences.Tables[1].Target.ForeignKeys[0].Columns.Should().HaveCount(1);
Expand Down Expand Up @@ -631,7 +610,6 @@ public async Task CompareAsync()
differences.Tables[2].Source.Columns[0].Position.Should().Be(1);
differences.Tables[2].Source.Columns[0].Precision.Should().Be(10);
differences.Tables[2].Source.Columns[0].Scale.Should().Be(0);
differences.Tables[2].Source.Columns[0].SystemTypeId.Should().Be(56);
differences.Tables[2].Source.Columns[0].TypeName.Should().Be("int");
differences.Tables[2].Source.Indexes.Should().HaveCount(2);
differences.Tables[2].Source.Indexes[0].Columns.Should().HaveCount(1);
Expand Down Expand Up @@ -676,7 +654,8 @@ public async Task CompareAsync()

differences.UserTypes[0].Source.Name.Should().Be("TypeDifference");
differences.UserTypes[0].Target.Name.Should().Be("TypeDifference");
differences.UserTypes[0].Properties.Should().HaveCount(3);

differences.UserTypes[0].Properties.Should().HaveCount(2);

differences.UserTypes[0].Properties[0].Name.Should().Be("IsNullable");
differences.UserTypes[0].Properties[0].Source.Should().Be(false);
Expand All @@ -686,10 +665,6 @@ public async Task CompareAsync()
differences.UserTypes[0].Properties[1].Source.Should().Be(11);
differences.UserTypes[0].Properties[1].Target.Should().Be(4);

differences.UserTypes[0].Properties[2].Name.Should().Be("SystemTypeId");
differences.UserTypes[0].Properties[2].Source.Should().Be(167);
differences.UserTypes[0].Properties[2].Target.Should().Be(56);

differences.UserTypes[1].Source.Should().BeNull();
differences.UserTypes[1].Target.Name.Should().Be("TypeTarget");
differences.UserTypes[1].Type.Should().Be(SqlObjectDifferenceType.MissingInSource);
Expand Down

0 comments on commit 194590f

Please sign in to comment.