Repository navigation
Fix total count for empty pages - #10113
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adjusts empty-page handling so that TotalCount is correct for empty result pages, distinguishing between “known empty” (TotalCount = 0) and “empty but total count unknown” (TotalCount = null).
Changes:
- Redefines
Page<T>.Empty(viaValueCursorPage<T>.Empty) to represent a known-empty page withTotalCount = 0. - Updates EF paging helpers to preserve
totalCount(including non-zero counts) even when the returned page has no items. - Updates and adds tests to cover
TotalCountbehavior for empty pages and for “unknown total count” empty pages.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/HotChocolate/Core/test/Types.CursorPagination.Tests/PageConnectionTests.cs | Updates test setup to ensure “unknown total count” uses an empty page with TotalCount = null, while “known empty” uses Page.Empty. |
| src/GreenDonut/test/GreenDonut.Data.Tests/PageTests.cs | Adds coverage asserting Page.Empty.TotalCount == 0. |
| src/GreenDonut/src/GreenDonut.Data.Primitives/ValueCursorPage.cs | Changes ValueCursorPage.Empty to include totalCount = 0, affecting Page<T>.Empty. |
| src/GreenDonut/src/GreenDonut.Data.EntityFramework/Extensions/PagingQueryableExtensions.cs | Ensures empty pages returned from EF paging preserve totalCount instead of defaulting to Page.Empty. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Patch coverage100.0% of changed lines covered (3/3)
Project coverage: 53.7% (230653/429484 lines) |
|
|
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
No description provided.