Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2.5.4 #55

Merged
merged 1 commit into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

Represents the **NuGet** versions.

## v2.5.4
- *Fixed:* Updated `CoreEx` to version `3.21.0`.
- *Fixed:* Updated `DataParser` to set column with JSON (`JsonElement.GetRawText`) value versus throwing an exception when the JSON is an object or an array.

## v2.5.3
- *Fixed:* Updated `CoreEx` to version `3.20.0`.
- *Fixed:* Fixed logging of SQL statements to include the source: `FILE`, `RES` (embedded resource) or `SQL` (specified statement).
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.5.3</Version>
<Version>2.5.4</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>

<ItemGroup>
<PackageReference Include="CoreEx.Database.MySql" Version="3.20.0" />
<PackageReference Include="CoreEx.Database.MySql" Version="3.21.0" />
<PackageReference Include="dbup-mysql" Version="5.0.44" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/DbEx.Postgres/DbEx.Postgres.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="CoreEx.Database.Postgres" Version="3.20.0" />
<PackageReference Include="CoreEx.Database.Postgres" Version="3.21.0" />
<PackageReference Include="dbup-postgresql" Version="5.0.40" />
</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>

<ItemGroup>
<PackageReference Include="CoreEx.Database.SqlServer" Version="3.20.0" />
<PackageReference Include="CoreEx.Database.SqlServer" Version="3.21.0" />
<PackageReference Include="dbup-sqlserver" Version="5.0.40" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/DbEx/DbEx.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="CoreEx.Database" Version="3.20.0" />
<PackageReference Include="CoreEx.Database" Version="3.21.0" />
<PackageReference Include="OnRamp" Version="2.2.0" />
</ItemGroup>

Expand Down
11 changes: 8 additions & 3 deletions src/DbEx/Migration/Data/DataParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,16 @@ private async Task ParseTableJsonAsync(List<DataTable> tables, DataRow? parent,
switch (jr.Value.ValueKind)
{
case JsonValueKind.Object:
throw new DataParserException($"Table '{sdt.Schema}.{sdt.Name}' has unsupported '{jr.Name}' column value; must not be an object: {jr.Value}.");
row.AddColumn(jr.Name, jr.Value.GetRawText());
break;

case JsonValueKind.Array:
// Try parsing as a further described nested table configuration; i.e. representing a relationship.
await ParseTableJsonAsync(tables, row, sdt.Schema, jr, cancellationToken).ConfigureAwait(false);
// Try parsing as a further described nested table configuration (i.e. representing a relationship) or update column with JSON string.
if (sdt.DbTable.Columns.SingleOrDefault(x => x.Name == jr.Name) is null)
await ParseTableJsonAsync(tables, row, sdt.Schema, jr, cancellationToken).ConfigureAwait(false);
else
row.AddColumn(jr.Name, jr.Value.GetRawText());

break;

default:
Expand Down
2 changes: 1 addition & 1 deletion tests/DbEx.Test.Console/Data/Data.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
- { ContactId: 2, ContactType: I, Name: Jane, Phone: 1234, Addresses: [ { ContactAddressId: 20, ContactId: 2, Street: "1 Main Street" } ] }
- ^Person:
- { PersonId: 88, Name: '^(DbEx.Test.Console.RuntimeValues.Name, DbEx.Test.Console)' }
- { Name: '^(DefaultName)' }
- { Name: '^(DefaultName)', AddressJson: { Street: "Main St", City: "Maine" }, NicknamesJson: ["Gaz", "Baz"] }
- $Gender:
- X: Not specified
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
 CREATE TABLE [Test].[Person] (
[PersonId] UNIQUEIDENTIFIER NOT NULL DEFAULT (NEWSEQUENTIALID()) PRIMARY KEY,
[Name] NVARCHAR (200) NOT NULL,
[NicknamesJson] NVARCHAR (500) NULL,
[AddressJson] NVARCHAR (500) NULL,
[CreatedBy] NVARCHAR (200) NULL,
[CreatedDate] DATETIME2 NULL,
[UpdatedBy] NVARCHAR (200) NULL,
Expand Down
2 changes: 1 addition & 1 deletion tests/DbEx.Test/DatabaseSchemaTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ public async Task SqlServerSelectSchema()
Assert.AreEqual("[Test].[Person]", tab.QualifiedName);
Assert.IsFalse(tab.IsAView);
Assert.IsFalse(tab.IsRefData);
Assert.AreEqual(6, tab.Columns.Count);
Assert.AreEqual(8, tab.Columns.Count);
Assert.AreEqual(1, tab.PrimaryKeyColumns.Count);
Assert.AreEqual("Person", tab.DotNetName);
Assert.AreEqual("People", tab.PluralName);
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.9.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
Expand Down
4 changes: 4 additions & 0 deletions tests/DbEx.Test/SqlServerMigrationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ public async Task A130_MigrateAll_Console()
Name = dr.GetValue<string>("Name"),
CreatedBy = dr.GetValue<string>("CreatedBy"),
CreatedDate = dr.GetValue<DateTime>("CreatedDate"),
AddressJson = dr.GetValue<string>("AddressJson"),
NicknamesJson = dr.GetValue<string>("NicknamesJson")
}).ConfigureAwait(false)).ToList();

Assert.AreEqual(3, res.Count);
Expand All @@ -138,6 +140,8 @@ public async Task A130_MigrateAll_Console()
Assert.AreEqual("Bazza", row2.Name);
Assert.AreEqual(m.Args.DataParserArgs.UserName, row2.CreatedBy);
Assert.AreEqual(m.Args.DataParserArgs.DateTimeNow, row2.CreatedDate);
Assert.AreEqual("{\"Street\": \"Main St\", \"City\": \"Maine\"}", row2.AddressJson);
Assert.AreEqual("[\"Gaz\", \"Baz\"]", row2.NicknamesJson);

// Check that the stored procedure script was migrated and works!
res = (await db.StoredProcedure("[Test].[spGetContact]").Param("@ContactId", 2).SelectQueryAsync(dr => new
Expand Down
Loading