Skip to content

Conversation

@devin-ai-integration
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot commented Dec 3, 2025

Add pagination tests for TableAggregate with namespace and composite keys

Summary

Adds comprehensive pagination tests to investigate a customer-reported issue where paginate({ pageSize: 1 }) returned continueCursor: null despite 3 entries existing.

The tests cover the exact scenario reported:

  • TableAggregate with namespace: (doc) => doc.monthKey
  • Composite sortKey: (doc) => [-doc.totalPoints, doc._id]
  • pageSize: 1 with order: "asc"

Finding: All tests pass on the current codebase. This suggests either:

  1. The bug was fixed in a recent commit (possibly the boundToPosition inclusivity fix in 9b64e74)
  2. The customer is on an older version of @convex-dev/aggregate
  3. The customer's wrapper code incorrectly maps {cursor, isDone} to continueCursor

Note: The library returns {page, cursor, isDone} - there is no continueCursor field. The customer likely has wrapper code doing something like continueCursor = cursor || null which would incorrectly return null if cursor is an empty string.

Review & Testing Checklist for Human

  • Verify the test scenarios match the customer's actual usage pattern
  • Confirm with customer what version of @convex-dev/aggregate they're using
  • Ask customer to share their wrapper code that exposes continueCursor
  • Note: example/convex/aggregate.test.ts has a pre-existing failure related to @convex-dev/migrations package (unrelated to this PR)

Notes

…keys

This adds tests that validate pagination behavior for the exact scenario
reported by a customer:
- TableAggregate with namespace function
- Composite sortKey: [-doc.totalPoints, doc._id]
- pageSize=1 with order='asc'

Tests verify:
1. paginate with pageSize=1 returns cursor when more items exist
2. paginate with pageSize=1 iterates through all items correctly
3. paginate with pageSize=10 returns all items at once
4. iter with namespace and composite keys works correctly

Also adds B-tree level pagination tests to verify the core implementation.

All tests pass on the current codebase, indicating the reported issue
may be fixed in the current version or related to customer wrapper code.

Co-Authored-By: Ian Macartney <[email protected]>
@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@coderabbitai
Copy link

coderabbitai bot commented Dec 3, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch devin/1764723606-pagination-tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 3, 2025

Open in StackBlitz

npm i https://pkg.pr.new/get-convex/aggregate/@convex-dev/aggregate@165

commit: 2e873eb

@devin-ai-integration
Copy link
Contributor Author

Closing due to inactivity for more than 7 days. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant