Skip to content

Commit

Permalink
Merge pull request #946 from DuendeSoftware/brock/QuerySessionsAsync_…
Browse files Browse the repository at this point in the history
…filter_fix

fix incorrect filtering logic in QuerySessionsAsync
  • Loading branch information
brockallen authored Jul 12, 2022
2 parents 366557b + 50323c0 commit 68c45f1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/EntityFramework.Storage/Stores/ServerSideSessionStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,8 @@ public virtual async Task<QueryResult<ServerSideSession>> QuerySessionsAsync(Ses
!String.IsNullOrWhiteSpace(filter.SessionId))
{
query = query.Where(x =>
(filter.SubjectId == null || x.SubjectId.Contains(filter.SubjectId)) ||
(filter.SessionId == null || x.SessionId.Contains(filter.SessionId)) ||
(filter.SubjectId == null || x.SubjectId.Contains(filter.SubjectId)) &&
(filter.SessionId == null || x.SessionId.Contains(filter.SessionId)) &&
(filter.DisplayName == null || (x.DisplayName != null && x.DisplayName.Contains(filter.DisplayName) == true))
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ public Task<QueryResult<ServerSideSession>> QuerySessionsAsync(SessionQuery filt
!String.IsNullOrWhiteSpace(filter.SessionId))
{
query = query.Where(x =>
(filter.SubjectId == null || x.SubjectId.Contains(filter.SubjectId)) ||
(filter.SessionId == null || x.SessionId.Contains(filter.SessionId)) ||
(filter.SubjectId == null || x.SubjectId.Contains(filter.SubjectId)) &&
(filter.SessionId == null || x.SessionId.Contains(filter.SessionId)) &&
(filter.DisplayName == null || (x.DisplayName != null && x.DisplayName.Contains(filter.DisplayName) == true))
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,13 @@ public async Task querysessions_on_ticket_store_should_use_session_store()
_pipeline.RemoveLoginCookie();
await _pipeline.LoginAsync("alice");
_pipeline.RemoveLoginCookie();
await _pipeline.LoginAsync("alice");
await _pipeline.LoginAsync("bob");
_pipeline.RemoveLoginCookie();

var tickets = await _ticketService.QuerySessionsAsync(new SessionQuery { SubjectId = "alice" });
tickets.TotalCount.Should().Be(2);
var sessions = await _sessionStore.QuerySessionsAsync(new SessionQuery { SubjectId = "alice" });
sessions.TotalCount.Should().Be(2);

tickets.ResultsToken.Should().Be(sessions.ResultsToken);
tickets.HasPrevResults.Should().Be(sessions.HasPrevResults);
Expand Down

0 comments on commit 68c45f1

Please sign in to comment.