Skip to content

Commit

Permalink
V2.3.8 (#42)
Browse files Browse the repository at this point in the history
* Fix MAX length.

* Fix typo.
  • Loading branch information
chullybun committed Aug 19, 2023
1 parent ee77a1b commit a1aff1f
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

Represents the **NuGet** versions.

## v2.3.8
- *Fixed:* `SqlServerMigration` has been fixed to handle column size of `MAX` correctly.

## v2.3.7
- *Fixed:* `SqlServerMigration` updated to correct the `DataResetFilterPredicate` to exclude all tables within schema `cdc`, and exclude all tables within the `dbo` schema where the table name starts with `sys`. This is to ensure that the internal Change Data tables are not reset, and that any SQL Server system tables are not inadvertently reset.

Expand Down
2 changes: 1 addition & 1 deletion Common.targets
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>2.3.7</Version>
<Version>2.3.8</Version>
<LangVersion>preview</LangVersion>
<Authors>Avanade</Authors>
<Company>Avanade</Company>
Expand Down
2 changes: 1 addition & 1 deletion src/DbEx.MySql/DbEx.MySql.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<ItemGroup>
<PackageReference Include="CoreEx.Database.MySql" Version="3.3.0" />
<PackageReference Include="dbup-mysql" Version="5.0.10" />
<PackageReference Include="OnRamp" Version="1.0.7" />
<PackageReference Include="OnRamp" Version="1.0.8" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/DbEx.SqlServer/DbEx.SqlServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<ItemGroup>
<PackageReference Include="CoreEx.Database.SqlServer" Version="3.3.0" />
<PackageReference Include="dbup-sqlserver" Version="5.0.8" />
<PackageReference Include="OnRamp" Version="1.0.7" />
<PackageReference Include="OnRamp" Version="1.0.8" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/DbEx.SqlServer/SqlServerSchemaConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public override void PrepareDataParserArgs(DataParserArgs dataParserArgs)
public override DbColumnSchema CreateColumnFromInformationSchema(DbTableSchema table, DatabaseRecord dr) => new(table, dr.GetValue<string>("COLUMN_NAME"), dr.GetValue<string>("DATA_TYPE"))
{
IsNullable = dr.GetValue<string>("IS_NULLABLE").ToUpperInvariant() == "YES",
Length = (ulong?)dr.GetValue<int?>("CHARACTER_MAXIMUM_LENGTH"),
Length = (ulong?)(dr.GetValue<int?>("CHARACTER_MAXIMUM_LENGTH") <= 0 ? null : dr.GetValue<int?>("CHARACTER_MAXIMUM_LENGTH")),
Precision = (ulong?)(dr.GetValue<byte?>("NUMERIC_PRECISION") ?? dr.GetValue<short?>("DATETIME_PRECISION")),
Scale = (ulong?)dr.GetValue<int?>("NUMERIC_SCALE"),
DefaultValue = dr.GetValue<string>("COLUMN_DEFAULT")
Expand Down
2 changes: 1 addition & 1 deletion src/DbEx/DbEx.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<ItemGroup>
<PackageReference Include="CoreEx.Database" Version="3.3.0" />
<PackageReference Include="dbup-sqlserver" Version="5.0.8" />
<PackageReference Include="OnRamp" Version="1.0.7" />
<PackageReference Include="OnRamp" Version="1.0.8" />
</ItemGroup>

<Import Project="..\..\Common.targets" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
[ContactTypeId] INT NOT NULL DEFAULT 1,
[GenderId] INT NULL,
[TenantId] NVARCHAR(50),
[Notes] NVARCHAR(MAX) NULL,
CONSTRAINT [FK_Test_Contact_ContactType] FOREIGN KEY ([ContactTypeId]) REFERENCES [Test].[ContactType] ([ContactTypeId])
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
`date_of_birth` DATE NULL,
`contact_type_id` INT NOT NULL DEFAULT 1,
`gender_id` INT NULL,
`notes` TEXT NULL,
CONSTRAINT `FK_Test_Contact_ContactType` FOREIGN KEY (`contact_type_id`) REFERENCES `contact_type` (`contact_type_id`)
)
40 changes: 38 additions & 2 deletions tests/DbEx.Test/DatabaseSchemaTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public async Task SqlServerSelectSchema()
Assert.AreEqual("[Test].[Contact]", tab.QualifiedName);
Assert.IsFalse(tab.IsAView);
Assert.IsFalse(tab.IsRefData);
Assert.AreEqual(7, tab.Columns.Count);
Assert.AreEqual(8, tab.Columns.Count);
Assert.AreEqual(1, tab.PrimaryKeyColumns.Count);

col = tab.Columns[0];
Expand Down Expand Up @@ -192,6 +192,24 @@ public async Task SqlServerSelectSchema()
col = tab.Columns[6];
Assert.AreEqual("TenantId", col.Name);

col = tab.Columns[7];
Assert.AreEqual("Notes", col.Name);
Assert.AreEqual("nvarchar", col.Type);
Assert.AreEqual("NVARCHAR(MAX) NULL", col.SqlType);
Assert.IsNull(col.Length);
Assert.IsNull(col.Scale);
Assert.IsNull(col.Precision);
Assert.AreEqual("string", col.DotNetType);
Assert.IsTrue(col.IsNullable);
Assert.IsFalse(col.IsPrimaryKey);
Assert.IsFalse(col.IsIdentity);
Assert.IsNull(col.IdentitySeed);
Assert.IsNull(col.IdentityIncrement);
Assert.IsFalse(col.IsUnique);
Assert.IsFalse(col.IsComputed);
Assert.IsFalse(col.IsForeignRefData);
Assert.IsNull(col.DefaultValue);

// [Test].[MultiPk]
tab = tables.Where(x => x.Name == "MultiPk").SingleOrDefault();
Assert.IsNotNull(tab);
Expand Down Expand Up @@ -405,7 +423,7 @@ public async Task MySqlSelectSchema()
Assert.AreEqual("`contact`", tab.QualifiedName);
Assert.IsFalse(tab.IsAView);
Assert.IsFalse(tab.IsRefData);
Assert.AreEqual(6, tab.Columns.Count);
Assert.AreEqual(7, tab.Columns.Count);
Assert.AreEqual(1, tab.PrimaryKeyColumns.Count);

col = tab.Columns[0];
Expand Down Expand Up @@ -493,6 +511,24 @@ public async Task MySqlSelectSchema()
Assert.AreEqual("gender_id", col.ForeignColumn);
Assert.IsNull(col.DefaultValue);

col = tab.Columns[6];
Assert.AreEqual("notes", col.Name);
Assert.AreEqual("text", col.Type);
Assert.AreEqual("TEXT NULL", col.SqlType);
Assert.AreEqual(65535, col.Length);
Assert.IsNull(col.Scale);
Assert.IsNull(col.Precision);
Assert.AreEqual("string", col.DotNetType);
Assert.IsTrue(col.IsNullable);
Assert.IsFalse(col.IsPrimaryKey);
Assert.IsFalse(col.IsIdentity);
Assert.IsNull(col.IdentitySeed);
Assert.IsNull(col.IdentityIncrement);
Assert.IsFalse(col.IsUnique);
Assert.IsFalse(col.IsComputed);
Assert.IsFalse(col.IsForeignRefData);
Assert.IsNull(col.DefaultValue);

// [Test].[MultiPk]
tab = tables.Where(x => x.Name == "multi_pk").SingleOrDefault();
Assert.IsNotNull(tab);
Expand Down
2 changes: 1 addition & 1 deletion tests/DbEx.Test/DbEx.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="7.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.1" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="coverlet.collector" Version="6.0.0">
Expand Down

0 comments on commit a1aff1f

Please sign in to comment.