Skip to content

Commit cbdf698

Browse files
committed
fix(decimal): honor precision/scale in YdbTypeMappingSource
1 parent e959dbd commit cbdf698

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/EFCore.Ydb/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
- Fixed Decimal precision/scale mapping in EF provider and added functional tests.
12
- Supported Guid (Uuid YDB type).
23
- PrivateAssets="none" is set to flow the EF Core analyzer to users referencing this package [issue](https://github.com/aspnet/EntityFrameworkCore/pull/11350).
34

src/EFCore.Ydb/src/Storage/Internal/YdbTypeMappingSource.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,16 @@ RelationalTypeMappingSourceDependencies relationalDependencies
111111
};
112112

113113
protected override RelationalTypeMapping? FindMapping(in RelationalTypeMappingInfo mappingInfo)
114-
=> base.FindMapping(mappingInfo) ?? FindBaseMapping(mappingInfo)?.Clone(mappingInfo);
114+
{
115+
if (mappingInfo.ClrType == typeof(decimal)
116+
|| string.Equals(mappingInfo.StoreTypeNameBase, "Decimal", StringComparison.OrdinalIgnoreCase)
117+
|| string.Equals(mappingInfo.StoreTypeName, "Decimal", StringComparison.OrdinalIgnoreCase))
118+
{
119+
return Decimal.Clone(mappingInfo);
120+
}
121+
122+
return base.FindMapping(mappingInfo) ?? FindBaseMapping(mappingInfo)?.Clone(mappingInfo);
123+
}
115124

116125
private static RelationalTypeMapping? FindBaseMapping(in RelationalTypeMappingInfo mappingInfo)
117126
{

0 commit comments

Comments
 (0)