Skip to content

Commit 33d6cec

Browse files
authored
v2.5.4 (#55)
- *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.
1 parent d69847a commit 33d6cec

File tree

12 files changed

+26
-11
lines changed

12 files changed

+26
-11
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
Represents the **NuGet** versions.
44

5+
## v2.5.4
6+
- *Fixed:* Updated `CoreEx` to version `3.21.0`.
7+
- *Fixed:* Updated `DataParser` to set column with JSON (`JsonElement.GetRawText`) value versus throwing an exception when the JSON is an object or an array.
8+
59
## v2.5.3
610
- *Fixed:* Updated `CoreEx` to version `3.20.0`.
711
- *Fixed:* Fixed logging of SQL statements to include the source: `FILE`, `RES` (embedded resource) or `SQL` (specified statement).

Common.targets

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project>
22
<PropertyGroup>
3-
<Version>2.5.3</Version>
3+
<Version>2.5.4</Version>
44
<LangVersion>preview</LangVersion>
55
<Authors>Avanade</Authors>
66
<Company>Avanade</Company>

src/DbEx.MySql/DbEx.MySql.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
</ItemGroup>
4242

4343
<ItemGroup>
44-
<PackageReference Include="CoreEx.Database.MySql" Version="3.20.0" />
44+
<PackageReference Include="CoreEx.Database.MySql" Version="3.21.0" />
4545
<PackageReference Include="dbup-mysql" Version="5.0.44" />
4646
</ItemGroup>
4747

src/DbEx.Postgres/DbEx.Postgres.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
</ItemGroup>
4343

4444
<ItemGroup>
45-
<PackageReference Include="CoreEx.Database.Postgres" Version="3.20.0" />
45+
<PackageReference Include="CoreEx.Database.Postgres" Version="3.21.0" />
4646
<PackageReference Include="dbup-postgresql" Version="5.0.40" />
4747
</ItemGroup>
4848

src/DbEx.SqlServer/DbEx.SqlServer.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
</ItemGroup>
3333

3434
<ItemGroup>
35-
<PackageReference Include="CoreEx.Database.SqlServer" Version="3.20.0" />
35+
<PackageReference Include="CoreEx.Database.SqlServer" Version="3.21.0" />
3636
<PackageReference Include="dbup-sqlserver" Version="5.0.40" />
3737
</ItemGroup>
3838

src/DbEx/DbEx.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
</ItemGroup>
2121

2222
<ItemGroup>
23-
<PackageReference Include="CoreEx.Database" Version="3.20.0" />
23+
<PackageReference Include="CoreEx.Database" Version="3.21.0" />
2424
<PackageReference Include="OnRamp" Version="2.2.0" />
2525
</ItemGroup>
2626

src/DbEx/Migration/Data/DataParser.cs

+8-3
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,16 @@ private async Task ParseTableJsonAsync(List<DataTable> tables, DataRow? parent,
220220
switch (jr.Value.ValueKind)
221221
{
222222
case JsonValueKind.Object:
223-
throw new DataParserException($"Table '{sdt.Schema}.{sdt.Name}' has unsupported '{jr.Name}' column value; must not be an object: {jr.Value}.");
223+
row.AddColumn(jr.Name, jr.Value.GetRawText());
224+
break;
224225

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

230235
default:

tests/DbEx.Test.Console/Data/Data.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
- { ContactId: 2, ContactType: I, Name: Jane, Phone: 1234, Addresses: [ { ContactAddressId: 20, ContactId: 2, Street: "1 Main Street" } ] }
99
- ^Person:
1010
- { PersonId: 88, Name: '^(DbEx.Test.Console.RuntimeValues.Name, DbEx.Test.Console)' }
11-
- { Name: '^(DefaultName)' }
11+
- { Name: '^(DefaultName)', AddressJson: { Street: "Main St", City: "Maine" }, NicknamesJson: ["Gaz", "Baz"] }
1212
- $Gender:
1313
- X: Not specified

tests/DbEx.Test.Console/Migrations/006-create-test-person-table.sql

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
CREATE TABLE [Test].[Person] (
22
[PersonId] UNIQUEIDENTIFIER NOT NULL DEFAULT (NEWSEQUENTIALID()) PRIMARY KEY,
33
[Name] NVARCHAR (200) NOT NULL,
4+
[NicknamesJson] NVARCHAR (500) NULL,
5+
[AddressJson] NVARCHAR (500) NULL,
46
[CreatedBy] NVARCHAR (200) NULL,
57
[CreatedDate] DATETIME2 NULL,
68
[UpdatedBy] NVARCHAR (200) NULL,

tests/DbEx.Test/DatabaseSchemaTest.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ public async Task SqlServerSelectSchema()
331331
Assert.AreEqual("[Test].[Person]", tab.QualifiedName);
332332
Assert.IsFalse(tab.IsAView);
333333
Assert.IsFalse(tab.IsRefData);
334-
Assert.AreEqual(6, tab.Columns.Count);
334+
Assert.AreEqual(8, tab.Columns.Count);
335335
Assert.AreEqual(1, tab.PrimaryKeyColumns.Count);
336336
Assert.AreEqual("Person", tab.DotNetName);
337337
Assert.AreEqual("People", tab.PluralName);

tests/DbEx.Test/DbEx.Test.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="7.0.0" />
1212
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
1313
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="7.0.0" />
14-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
14+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
1515
<PackageReference Include="NUnit" Version="3.13.3" />
1616
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
1717
<PackageReference Include="coverlet.collector" Version="6.0.2">

tests/DbEx.Test/SqlServerMigrationTest.cs

+4
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ public async Task A130_MigrateAll_Console()
124124
Name = dr.GetValue<string>("Name"),
125125
CreatedBy = dr.GetValue<string>("CreatedBy"),
126126
CreatedDate = dr.GetValue<DateTime>("CreatedDate"),
127+
AddressJson = dr.GetValue<string>("AddressJson"),
128+
NicknamesJson = dr.GetValue<string>("NicknamesJson")
127129
}).ConfigureAwait(false)).ToList();
128130

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

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

0 commit comments

Comments
 (0)