Skip to content

fix(persistence): treat thread reply pagination limit of 0 as unset#2803

Draft
VelikovPetar wants to merge 2 commits into
masterfrom
fix/thread-replies-limit-zero
Draft

fix(persistence): treat thread reply pagination limit of 0 as unset#2803
VelikovPetar wants to merge 2 commits into
masterfrom
fix/thread-replies-limit-zero

Conversation

@VelikovPetar

Copy link
Copy Markdown
Contributor

Summary

MessageDao.getThreadMessagesByParentId recently moved offline thread-reply pagination into SQL. That change turned a PaginationParams.limit of 0 into a SQL LIMIT 0 (zero rows), whereas the pre-SQL implementation treated 0 as "unlimited" and returned every reply.

Across the stack, limit: 0 means unset, not "empty":

  • Backend getReplies: limit == 0 is treated as unset → default page of 100.
  • iOS (Core Data): fetchLimit == 0 → unlimited (all rows).
  • Flutter (pre-port): 0 → returned all rows.

This PR only applies the SQL LIMIT when a positive limit is provided, restoring the "0 = unset → return all matching replies" contract.

if (options != null && options.limit > 0) {
  query.limit(options.limit);
}

Low-risk in practice — PaginationParams.limit is non-nullable and defaults to 10, and no in-repo call site passes 0 — so this is a latent-correctness fix.

Scope is intentionally threads only. getMessagesByCid has the same unguarded pattern but is left untouched here.

Originally surfaced while reviewing #2750 (the v9 backport), where the same fix was applied.

Test

Added limit of 0 is treated as unset and returns all replies to the getThreadMessagesByParentId group: seeds 30 replies, queries with PaginationParams(limit: 0), asserts all 30 come back in ASC order. Full group passes locally.

🤖 Generated with Claude Code

`getThreadMessagesByParentId` moved thread reply pagination into SQL,
which turned a `limit` of 0 into `LIMIT 0` (zero rows). The pre-SQL
implementation treated 0 as "unlimited" and returned every reply, and
both the backend `getReplies` endpoint (0 -> default page) and the iOS
SDK (`fetchLimit` 0 -> all rows) treat 0 as unset rather than empty.

Only apply the SQL `LIMIT` for a positive limit so a limit of 0 keeps
returning all matching replies.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b5e93b9a-470c-42cb-bdd7-a7a03de44bb7

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

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/thread-replies-limit-zero

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.

❤️ Share

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

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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