Skip to content

Commit

Permalink
v2.5.5 (#56)
Browse files Browse the repository at this point in the history
- *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`).
  • Loading branch information
chullybun committed Jun 27, 2024
1 parent 33d6cec commit fef0f72
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 2 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.5.5
- *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`).

## 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.
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.4</Version>
<Version>2.5.5</Version>
<LangVersion>preview</LangVersion>
<Authors>Avanade</Authors>
<Company>Avanade</Company>
Expand Down
2 changes: 2 additions & 0 deletions src/DbEx/Migration/Data/DataParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,8 @@ private async Task ParseTableJsonAsync(List<DataTable> tables, DataRow? parent,

throw new DataParserException(msg);
}
else if (ParserArgs.ReplaceShorthandGuids && int.TryParse(value[1..], out var i))
return new Guid(i, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
else
return value;
}
Expand Down
6 changes: 6 additions & 0 deletions src/DbEx/Migration/Data/DataParserArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ public DataParserArgs Parameter(string key, object? value, bool overrideExisting
/// </summary>
public DataParserTableNameMappings TableNameMappings { get; } = [];

/// <summary>
/// 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>'
/// </summary>
public bool ReplaceShorthandGuids { get; set; } = true;

/// <summary>
/// Copy and replace from <paramref name="args"/>.
/// </summary>
Expand All @@ -152,6 +157,7 @@ public void CopyFrom(DataParserArgs args)
args.Parameters.ForEach(x => Parameters.Add(x.Key, x.Value));
TableNameMappings.Clear();
args.TableNameMappings.ForEach(x => TableNameMappings.Add(x.Key.ParsedSchema, x.Key.ParsedTable, x.Value.Schema, x.Value.Table, x.Value.ColumnMappings));
ReplaceShorthandGuids = args.ReplaceShorthandGuids;
}
}
}
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 @@ -7,7 +7,7 @@
- { ContactId: 1, ContactType: E, Gender: M, Name: Bob, DateOfBirth: 2001-10-22, Addresses: [ { ContactAddressId: 10, Street: "1 Main Street" } ] }
- { 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)' }
- { PersonId: ^88, Name: '^(DbEx.Test.Console.RuntimeValues.Name, DbEx.Test.Console)' }
- { Name: '^(DefaultName)', AddressJson: { Street: "Main St", City: "Maine" }, NicknamesJson: ["Gaz", "Baz"] }
- $Gender:
- X: Not specified

0 comments on commit fef0f72

Please sign in to comment.