Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for #19444 - NET Core 3.1 Required String Properties - SqlException: An expression of non-boolean type specified in a context where a condition is expected, near 'THEN'. #19685

Merged
merged 1 commit into from
Jan 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 24 additions & 14 deletions test/EFCore.Specification.Tests/Query/GearsOfWarQueryTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7471,28 +7471,28 @@ public virtual Task Can_OrderBy_indexed_properties(bool async)

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Can_group_by_indexed_property_on_query(bool isAsync)
public virtual Task Can_group_by_indexed_property_on_query(bool async)
{
return AssertQueryScalar(
isAsync,
async,
ss => ss.Set<City>().GroupBy(c => c["Nation"]).Select(g => g.Count()));
}

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Can_group_by_converted_indexed_property_on_query(bool isAsync)
public virtual Task Can_group_by_converted_indexed_property_on_query(bool async)
{
return AssertQueryScalar(
isAsync,
async,
ss => ss.Set<City>().GroupBy(c => (string)c["Nation"]).Select(g => g.Count()));
}

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Can_join_on_indexed_property_on_query(bool isAsync)
public virtual Task Can_join_on_indexed_property_on_query(bool async)
{
return AssertQuery(
isAsync,
async,
ss =>
(from c1 in ss.Set<City>()
join c2 in ss.Set<City>()
Expand All @@ -7502,41 +7502,51 @@ on c1["Nation"] equals c2["Nation"]

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Projecting_index_property_ignores_include(bool isAsync)
public virtual Task Projecting_index_property_ignores_include(bool async)
{
return AssertQuery(
isAsync,
async,
ss => from c in ss.Set<City>().Include(c => c.BornGears).AsTracking()
select new { Nation = c["Nation"] });
}

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Indexer_property_is_pushdown_into_subquery(bool isAsync)
public virtual Task Indexer_property_is_pushdown_into_subquery(bool async)
{
return AssertQuery(
isAsync,
async,
ss => ss.Set<Gear>().Where(g => ss.Set<City>().Where(c => c.Name == g.CityOfBirthName).FirstOrDefault()["Nation"] == null));
}

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Conditional_with_conditions_evaluating_to_false_gets_optimized(bool isAsync)
public virtual Task Conditional_with_conditions_evaluating_to_false_gets_optimized(bool async)
{
return AssertQuery(
isAsync,
async,
ss => ss.Set<Gear>().Select(g => g.Nickname == null && g.Nickname != null ? g.CityOfBirthName : g.FullName));
}

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Conditional_with_conditions_evaluating_to_true_gets_optimized(bool isAsync)
public virtual Task Conditional_with_conditions_evaluating_to_true_gets_optimized(bool async)
{
return AssertQuery(
isAsync,
async,
ss => ss.Set<Gear>().Select(g => g.Nickname == null || g.Nickname != null ? g.CityOfBirthName : g.FullName));
}

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Projecting_required_string_column_compared_to_null_parameter(bool async)
{
var nullParameter = default(string);

return AssertQueryScalar(
async,
ss => ss.Set<Gear>().Select(g => g.Nickname == nullParameter));
}

protected GearsOfWarContext CreateContext() => Fixture.CreateContext();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7445,48 +7445,48 @@ WHERE [c].[Nation] IS NOT NULL
ORDER BY [c].[Nation], [c].[Name]");
}

public override async Task Can_group_by_indexed_property_on_query(bool isAsync)
public override async Task Can_group_by_indexed_property_on_query(bool async)
{
await base.Can_group_by_indexed_property_on_query(isAsync);
await base.Can_group_by_indexed_property_on_query(async);

AssertSql(
@"SELECT COUNT(*)
FROM [Cities] AS [c]
GROUP BY [c].[Nation]");
}

public override async Task Can_group_by_converted_indexed_property_on_query(bool isAsync)
public override async Task Can_group_by_converted_indexed_property_on_query(bool async)
{
await base.Can_group_by_converted_indexed_property_on_query(isAsync);
await base.Can_group_by_converted_indexed_property_on_query(async);

AssertSql(
@"SELECT COUNT(*)
FROM [Cities] AS [c]
GROUP BY [c].[Nation]");
}

public override async Task Can_join_on_indexed_property_on_query(bool isAsync)
public override async Task Can_join_on_indexed_property_on_query(bool async)
{
await base.Can_join_on_indexed_property_on_query(isAsync);
await base.Can_join_on_indexed_property_on_query(async);

AssertSql(
@"SELECT [c].[Name], [c0].[Location]
FROM [Cities] AS [c]
INNER JOIN [Cities] AS [c0] ON [c].[Nation] = [c0].[Nation]");
}

public override async Task Projecting_index_property_ignores_include(bool isAsync)
public override async Task Projecting_index_property_ignores_include(bool async)
{
await base.Projecting_index_property_ignores_include(isAsync);
await base.Projecting_index_property_ignores_include(async);

AssertSql(
@"SELECT [c].[Nation]
FROM [Cities] AS [c]");
}

public override async Task Indexer_property_is_pushdown_into_subquery(bool isAsync)
public override async Task Indexer_property_is_pushdown_into_subquery(bool async)
{
await base.Indexer_property_is_pushdown_into_subquery(isAsync);
await base.Indexer_property_is_pushdown_into_subquery(async);

AssertSql(
@"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank]
Expand All @@ -7497,26 +7497,36 @@ FROM [Cities] AS [c]
WHERE [c].[Name] = [g].[CityOfBirthName]) IS NULL");
}

public override async Task Conditional_with_conditions_evaluating_to_false_gets_optimized(bool isAsync)
public override async Task Conditional_with_conditions_evaluating_to_false_gets_optimized(bool async)
{
await base.Conditional_with_conditions_evaluating_to_false_gets_optimized(isAsync);
await base.Conditional_with_conditions_evaluating_to_false_gets_optimized(async);

AssertSql(
@"SELECT [g].[FullName]
FROM [Gears] AS [g]
WHERE [g].[Discriminator] IN (N'Gear', N'Officer')");
}

public override async Task Conditional_with_conditions_evaluating_to_true_gets_optimized(bool isAsync)
public override async Task Conditional_with_conditions_evaluating_to_true_gets_optimized(bool async)
{
await base.Conditional_with_conditions_evaluating_to_true_gets_optimized(isAsync);
await base.Conditional_with_conditions_evaluating_to_true_gets_optimized(async);

AssertSql(
@"SELECT [g].[CityOfBirthName]
FROM [Gears] AS [g]
WHERE [g].[Discriminator] IN (N'Gear', N'Officer')");
}

public override async Task Projecting_required_string_column_compared_to_null_parameter(bool async)
{
await base.Projecting_required_string_column_compared_to_null_parameter(async);

AssertSql(
@"SELECT CAST(0 AS bit)
FROM [Gears] AS [g]
WHERE [g].[Discriminator] IN (N'Gear', N'Officer')");
}

private void AssertSql(params string[] expected)
=> Fixture.TestSqlLoggerFactory.AssertBaseline(expected);
}
Expand Down