Skip to content

Commit 292fc7d

Browse files
committed
try
1 parent aa02060 commit 292fc7d

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,13 @@ RelationalTypeMappingSourceDependencies relationalDependencies
111111
{ typeof(TimeSpan), Interval }
112112
};
113113

114-
private static readonly ConcurrentDictionary<RelationalTypeMappingInfo, RelationalTypeMapping> DecimalCache = new();
114+
private readonly ConcurrentDictionary<RelationalTypeMappingInfo, RelationalTypeMapping> _decimalCache = new();
115115

116116
protected override RelationalTypeMapping? FindMapping(in RelationalTypeMappingInfo mappingInfo)
117117
{
118118
if (mappingInfo.ClrType == typeof(decimal))
119119
{
120-
return DecimalCache.GetOrAdd(mappingInfo, static mi => Decimal.Clone(mi));
120+
return _decimalCache.GetOrAdd(mappingInfo, static mi => Decimal.Clone(mi));
121121
}
122122

123123
return base.FindMapping(mappingInfo) ?? FindBaseMapping(mappingInfo)?.Clone(mappingInfo);

src/EFCore.Ydb/test/EntityFrameworkCore.Ydb.FunctionalTests/Query/DecimalParameterizedYdbTheoryTest.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ namespace EntityFrameworkCore.Ydb.FunctionalTests.Query;
99
public class DecimalParameterizedYdbTheoryTest(DecimalParameterQueryYdbFixture fixture)
1010
: IClassFixture<DecimalParameterQueryYdbFixture>
1111
{
12+
static DecimalParameterizedYdbTheoryTest()
13+
=> AppContext.SetSwitch("EntityFrameworkCore.Ydb.EnableParametrizedDecimal", true);
14+
1215
private DbContextOptions<ParametricDecimalContext> BuildOptions()
1316
{
1417
using var baseCtx = fixture.CreateContext();
@@ -91,6 +94,7 @@ public async Task Decimal_roundtrips_or_rounds_like_ado(int p, int s, decimal va
9194
[MemberData(nameof(OverflowCases))]
9295
public async Task Decimal_overflow_bubbles_up(int p, int s, decimal value)
9396
{
97+
AppContext.SetSwitch("EntityFrameworkCore.Ydb.EnableParametrizedDecimal", true);
9498
await using var ctx = NewCtx(p, s);
9599
await ctx.Database.EnsureCreatedAsync();
96100

src/EFCore.Ydb/test/EntityFrameworkCore.Ydb.FunctionalTests/Query/ParametricDecimalContext.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,9 @@ internal sealed class CacheKeyFactory : IModelCacheKeyFactory
3030
public object Create(DbContext context, bool designTime)
3131
{
3232
var ctx = (ParametricDecimalContext)context;
33+
var flag = AppContext.TryGetSwitch("EntityFrameworkCore.Ydb.EnableParametrizedDecimal", out var on) && on;
3334

34-
var options = context.GetService<IDbContextOptions>();
35-
36-
return (context.GetType(), designTime, ctx._p, ctx._s, options.Extensions);
35+
return (context.GetType(), designTime, ctx._p, ctx._s, flag);
3736
}
3837
}
3938
}

0 commit comments

Comments
 (0)