fix: ensure that paging forward and backward yields the same first page #144
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.
My implementation of paging has a seriously confusing bug that I caught while preparing for a demo - if you paged forward and then paged backward, the list you got after paging backward would look like the original list but have its start and end cursors reversed. It would also be in the reverse order. We knew about the reverse ordering but didn't catch its implications for cursors.
This happens because when you passed
pre
, Dynamo would evaluate and list keys in reverse order.This all brought me around to the opinion that we should always list keys in the same order, and make sure we swap endCursor and startCursor when
pre
is passed.This PR adds tests to ensure that paging forward once and then backward does indeed give the same list of keys, in the same order, with the same
startCursor
andendCursor
.The power of demos!