Skip to content

Commit

Permalink
Add test verifying #15208
Browse files Browse the repository at this point in the history
DateTimeOffset and Contains()

Fixes #15208
  • Loading branch information
roji committed Jun 28, 2019
1 parent a2ce460 commit 36771df
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/EFCore.Specification.Tests/Query/GearsOfWarQueryTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7513,6 +7513,22 @@ public virtual Task Bool_projection_from_subquery_treated_appropriately_in_where
(cs, gs) => cs.Where(c => gs.OrderBy(g => g.Nickname).ThenBy(g => g.SquadId).FirstOrDefault().HasSoulPatch));
}

[ConditionalTheory] // issue #15208
[MemberData(nameof(IsAsyncData))]
public virtual Task DateTimeOffset_Contains_Less_than_Greater_than(bool isAsync)
{
var dto = new DateTimeOffset(599898024001234567, new TimeSpan(1, 30, 0));
var start = dto.AddDays(-1);
var end = dto.AddDays(1);
var dates = new DateTimeOffset[] { dto };

return AssertQuery<Mission>(
isAsync,
ms => ms.Where(m => start <= m.Timeline.Date &&
m.Timeline < end &&
dates.Contains(m.Timeline)));
}

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

protected virtual void ClearLog()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8446,6 +8446,18 @@ WHERE [g].[Discriminator] IN (N'Gear', N'Officer')
ORDER BY [g].[Nickname], [g].[SquadId]) = CAST(1 AS bit)");
}

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

AssertSql(
@"@__start_0='1902-01-01T10:00:00.1234567+01:30'
@__end_1='1902-01-03T10:00:00.1234567+01:30'
SELECT [m].[Id], [m].[CodeName], [m].[Rating], [m].[Timeline]
FROM [Missions] AS [m]
WHERE ((@__start_0 <= CAST(CONVERT(date, [m].[Timeline]) AS datetimeoffset)) AND ([m].[Timeline] < @__end_1)) AND [m].[Timeline] IN ('1902-01-02T10:00:00.1234567+01:30')"); }

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,8 @@ public GearsOfWarQuerySqliteTest(GearsOfWarQuerySqliteFixture fixture)

// Skip for SQLite. Issue #14935. Cannot eval 'where ([m].Timeline.Year == 2)'
public override Task Where_datetimeoffset_year_component(bool isAsync) => null;

// Skip for SQLite. Issue #14935. Cannot eval 'where ([m].Timeline >= x)'
public override Task DateTimeOffset_Contains_Less_than_Greater_than(bool isAsync) => null;
}
}

0 comments on commit 36771df

Please sign in to comment.