Skip to content

Commit fef0f72

Browse files
authored
v2.5.5 (#56)
- *Fixed:* Updated `DataParser` to set column with a guid representation of an integer where specified using shorthand notation; i.e. replace `^n` values where `n` is an integer with a guid equivalent; e.g. `^1` will be converted to `00000001-0000-0000-0000-000000000000`. A new `DataParserArgs.ReplaceShorthandGuids` had been added to control this behavior (defaults to `true`).
1 parent 33d6cec commit fef0f72

File tree

5 files changed

+13
-2
lines changed

5 files changed

+13
-2
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
Represents the **NuGet** versions.
44

5+
## v2.5.5
6+
- *Fixed:* Updated `DataParser` to set column with a guid representation of an integer where specified using shorthand notation; i.e. replace `^n` values where `n` is an integer with a guid equivalent; e.g. `^1` will be converted to `00000001-0000-0000-0000-000000000000`. A new `DataParserArgs.ReplaceShorthandGuids` had been added to control this behavior (defaults to `true`).
7+
58
## v2.5.4
69
- *Fixed:* Updated `CoreEx` to version `3.21.0`.
710
- *Fixed:* Updated `DataParser` to set column with JSON (`JsonElement.GetRawText`) value versus throwing an exception when the JSON is an object or an array.

Common.targets

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

src/DbEx/Migration/Data/DataParser.cs

+2
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,8 @@ private async Task ParseTableJsonAsync(List<DataTable> tables, DataRow? parent,
317317

318318
throw new DataParserException(msg);
319319
}
320+
else if (ParserArgs.ReplaceShorthandGuids && int.TryParse(value[1..], out var i))
321+
return new Guid(i, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
320322
else
321323
return value;
322324
}

src/DbEx/Migration/Data/DataParserArgs.cs

+6
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,11 @@ public DataParserArgs Parameter(string key, object? value, bool overrideExisting
131131
/// </summary>
132132
public DataParserTableNameMappings TableNameMappings { get; } = [];
133133

134+
/// <summary>
135+
/// Indiates whether to replace '<c>^n</c>' values where '<c>n</c>' is an integer with a <see cref="Guid"/> equivalent; e.g. '<c>^1</c>' will be '<c>00000001-0000-0000-0000-000000000000</c>'
136+
/// </summary>
137+
public bool ReplaceShorthandGuids { get; set; } = true;
138+
134139
/// <summary>
135140
/// Copy and replace from <paramref name="args"/>.
136141
/// </summary>
@@ -152,6 +157,7 @@ public void CopyFrom(DataParserArgs args)
152157
args.Parameters.ForEach(x => Parameters.Add(x.Key, x.Value));
153158
TableNameMappings.Clear();
154159
args.TableNameMappings.ForEach(x => TableNameMappings.Add(x.Key.ParsedSchema, x.Key.ParsedTable, x.Value.Schema, x.Value.Table, x.Value.ColumnMappings));
160+
ReplaceShorthandGuids = args.ReplaceShorthandGuids;
155161
}
156162
}
157163
}

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

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

0 commit comments

Comments
 (0)