Repository navigation
fix(entry)!: expose pagination for transaction entries - #915
Open
SIDDHANTCOOKIE wants to merge 2 commits into
Open
SIDDHANTCOOKIE wants to merge 2 commits into
SIDDHANTCOOKIE wants to merge 2 commits into
Conversation
Author
|
@bodymindarts could you review this fix when you have a chance? I reproduced #914 against PostgreSQL: a transaction with 102 persisted entries returns only 100 from |
Member
|
Instead of collecting internally we should probably expose the cursor in the public API. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Entries::list_for_transaction_idsilently returned only the first 100 entries while presenting a completeVec<Entry>. A transaction with 102 persisted entries therefore returned only 100 through this API.Expose pagination in the public method, consistent with other entry-listing methods: accept
PaginatedQueryArgs<EntryByCreatedAtCursor>andListDirection, and returnPaginatedQueryRet<Entry, EntryByCreatedAtCursor>. Callers decide whether to fetch subsequent pages. This follows the maintainer's requested API direction.Fixes #914.
Breaking API change
Callers now provide query arguments and direction, then handle
Page::Lastor followPage::HasNext.next. Entries follow the cursor's(created_at, id)ordering. Callers needing transaction sequence order should sort collected entries byentry.values().sequence.No database migration is needed. Existing transaction-batch callers explicitly expect one page; the sequence-sensitive caller sorts by sequence.
Validation
transaction_batchintegration tests pass.git diff --checkpass.Commands run with
SQLX_OFFLINE=trueandPG_CONpointing to a local test database:cargo test --locked -p cala-ledger --test transaction_entry_pagination --test transaction_batch -- --test-threads=2Note
Medium Risk
Breaking public API change; callers must paginate and may see different default ordering than the old implicit sequence sort, though behavior is now correct for large transactions.
Overview
Breaking fix:
Entries::list_for_transaction_idno longer returns a fullVec<Entry>that implicitly stopped at the first repository page (~100 rows). It now matches other entry list APIs: callers passPaginatedQueryArgs<EntryByCreatedAtCursor>andListDirection, receivePaginatedQueryRet, and followPage::HasNextfor additional pages. Results are ordered by(created_at, id); sequence order is left to callers viaentry.values().sequence.Docs on the method describe pagination and ordering.
transaction_batchintegration tests usehelpers::expect_single_pageand sort by sequence where assertions need posting order.A new
transaction_entry_paginationtest exercises counts above the old ceiling (102, 250), multiple page sizes, ascending/descending traversal, cursor continuity, and empty results for unknown transaction IDs.Reviewed by Cursor Bugbot for commit a9a013e. Bugbot is set up for automated code reviews on this repo. Configure here.