Skip to content

Commit f364295

Browse files
committed
Test additional cases of imprecise typemapping computation
1 parent 2ea7192 commit f364295

File tree

3 files changed

+78
-1
lines changed

3 files changed

+78
-1
lines changed

test/EFCore.Cosmos.FunctionalTests/Query/NorthwindMiscellaneousQueryCosmosTest.cs

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3269,6 +3269,38 @@ public override Task Coalesce_Correct_TypeMapping_String(bool async)
32693269
SELECT VALUE ((c["Region"] != null) ? c["Region"] : "no region specified")
32703270
FROM root c
32713271
ORDER BY c["id"]
3272+
""");
3273+
});
3274+
3275+
public override Task Coalesce_Correct_TypeMapping_String_Sum(bool async)
3276+
=> Fixture.NoSyncTest(
3277+
async, async a =>
3278+
{
3279+
await base.Coalesce_Correct_TypeMapping_String_Sum(async);
3280+
3281+
AssertSql(
3282+
"""
3283+
SELECT VALUE ((((c["Region"] != null) ? ("R" || c["Region"]) : null) != null) ? ((c["Region"] != null) ? ("R" || c["Region"]) : null) : "no region specified")
3284+
FROM root c
3285+
ORDER BY c["id"]
3286+
""");
3287+
});
3288+
3289+
public override Task Coalesce_Correct_TypeMapping_String_Join(bool async)
3290+
=> Fixture.NoSyncTest(
3291+
async, async a =>
3292+
{
3293+
await base.Coalesce_Correct_TypeMapping_String_Join(async);
3294+
3295+
AssertSql(
3296+
"""
3297+
SELECT VALUE
3298+
{
3299+
"c" : (c["Region"] != null),
3300+
"c0" : ["R", c["Region"]]
3301+
}
3302+
FROM root c
3303+
ORDER BY c["id"]
32723304
""");
32733305
});
32743306

@@ -3390,7 +3422,7 @@ public override async Task SelectMany_primitive_select_subquery(bool async)
33903422
// Cosmos client evaluation. Issue #17246.
33913423
Assert.Equal(
33923424
CoreStrings.ExpressionParameterizationExceptionSensitive(
3393-
"value(Microsoft.EntityFrameworkCore.Query.NorthwindMiscellaneousQueryTestBase`1+<>c__DisplayClass175_0[Microsoft.EntityFrameworkCore.Query.NorthwindQueryCosmosFixture`1[Microsoft.EntityFrameworkCore.TestUtilities.NoopModelCustomizer]]).ss.Set().Any()"),
3425+
"value(Microsoft.EntityFrameworkCore.Query.NorthwindMiscellaneousQueryTestBase`1+<>c__DisplayClass177_0[Microsoft.EntityFrameworkCore.Query.NorthwindQueryCosmosFixture`1[Microsoft.EntityFrameworkCore.TestUtilities.NoopModelCustomizer]]).ss.Set().Any()"),
33943426
(await Assert.ThrowsAsync<InvalidOperationException>(
33953427
() => base.SelectMany_primitive_select_subquery(async))).Message);
33963428

test/EFCore.Specification.Tests/Query/NorthwindMiscellaneousQueryTestBase.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,23 @@ public virtual Task Coalesce_Correct_TypeMapping_String(bool async)
748748
ss => ss.Set<Customer>().OrderBy(c => c.CustomerID).Select(c => c.Region ?? "no region specified"),
749749
assertOrder: true);
750750

751+
[ConditionalTheory]
752+
[MemberData(nameof(IsAsyncData))]
753+
public virtual Task Coalesce_Correct_TypeMapping_String_Sum(bool async)
754+
=> AssertQuery(
755+
async,
756+
ss => ss.Set<Customer>().OrderBy(c => c.CustomerID).Select(c => (c.Region != null ? "R" + c.Region : null) ?? "no region specified"),
757+
assertOrder: true);
758+
759+
[ConditionalTheory]
760+
[MemberData(nameof(IsAsyncData))]
761+
public virtual Task Coalesce_Correct_TypeMapping_String_Join(bool async)
762+
=> AssertQuery(
763+
async,
764+
ss => ss.Set<Customer>().OrderBy(c => c.CustomerID)
765+
.Select(c => (c.Region != null ? string.Join("|", new[] { "R", c.Region }) : null) ?? "no region specified"),
766+
assertOrder: true);
767+
751768
[ConditionalTheory]
752769
[MemberData(nameof(IsAsyncData))]
753770
public virtual Task Null_Coalesce_Short_Circuit(bool async)

test/EFCore.SqlServer.FunctionalTests/Query/NorthwindMiscellaneousQuerySqlServerTest.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2879,6 +2879,34 @@ ORDER BY [c].[CustomerID]
28792879
""");
28802880
}
28812881

2882+
public override async Task Coalesce_Correct_TypeMapping_String_Sum(bool async)
2883+
{
2884+
await base.Coalesce_Correct_TypeMapping_String_Sum(async);
2885+
2886+
AssertSql(
2887+
"""
2888+
SELECT COALESCE(CASE
2889+
WHEN [c].[Region] IS NOT NULL THEN N'R' + [c].[Region]
2890+
END, N'no region specified')
2891+
FROM [Customers] AS [c]
2892+
ORDER BY [c].[CustomerID]
2893+
""");
2894+
}
2895+
2896+
public override async Task Coalesce_Correct_TypeMapping_String_Join(bool async)
2897+
{
2898+
await base.Coalesce_Correct_TypeMapping_String_Join(async);
2899+
2900+
AssertSql(
2901+
"""
2902+
SELECT COALESCE(CASE
2903+
WHEN [c].[Region] IS NOT NULL THEN CONCAT_WS(N'|', N'R', [c].[Region])
2904+
END, N'no region specified')
2905+
FROM [Customers] AS [c]
2906+
ORDER BY [c].[CustomerID]
2907+
""");
2908+
}
2909+
28822910
public override async Task Null_Coalesce_Short_Circuit(bool async)
28832911
{
28842912
await base.Null_Coalesce_Short_Circuit(async);

0 commit comments

Comments
 (0)