Repository navigation
feat: count typed query scopes for pagination - #526
Conversation
✅ Deploy Preview for prisma-dart canceled.
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (9)
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe query API adds ChangesScoped Counts and Search Pages
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Feature Sequence Diagram(s)sequenceDiagram
participant searchUsers
participant TableQuery
participant Database
searchUsers->>TableQuery: count matching users
TableQuery->>Database: execute COUNT(*) SELECT
Database-->>TableQuery: return total
searchUsers->>TableQuery: select ordered page with offset and limit
TableQuery->>Database: execute page SELECT
Database-->>searchUsers: return page rows
Merge Risk: ⚪ Minimal · up to No actionable merge blocker is identified; complete the planned final-head checks before merging. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. A rabbit counts each row with care Comment |
Problem and behavior
Typed user search could return a page, but obtaining its filtered total required loading every model or duplicating the predicates in raw SQL. Add
count()to the immutable query scope and generated table facade: one parameterized SELECT returns one integer without selecting or decoding model fields.Count includes the scope's limit/offset. An unpaged scope uses direct COUNT; a paged scope counts a SELECT 1 derived table, with existing SQLite/PostgreSQL pagination binding shared by reads. Sorting is omitted because it does not change cardinality. No aggregate framework or pagination class is added.
The complete
searchUsersexample now returns(users: ..., total: ...), validates offset/limit and reuses one typed AND/OR filter scope for total + selected page in one read-only transaction. Empty or later pages retain the filtered total. Directpage.users.first.usernameremains typed.Refs #516
Validation and upgrade
.usersand.total; no compatibility wrapper is introduced. Frozen schemas, reviewed migration definitions and fingerprints are unchanged.Summary by CodeRabbit
count()to query APIs, returning the number of rows in the current scope, including any limit and offset.