-
Notifications
You must be signed in to change notification settings - Fork 66
Triggers: Fix patch/delete with explicit table names
#881
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughAdds a denormalized Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Server as MutationHandler
participant Triggers
participant DB
Client->>Server: call createUser / updateUser / deleteUser
Server->>DB: perform insert/patch/delete (explicit id allowed)
Server->>Triggers: _queueTriggers checks registered[table] (now defaults to [])
Triggers-->>DB: run trigger handlers (e.g., update userCount) if any
DB-->>Server: ack
Server-->>Client: result
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20–30 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (1)**/*.{ts,tsx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧬 Code graph analysis (1)packages/convex-helpers/server/triggers.test.ts (2)
🔇 Additional comments (6)
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. Comment |
commit: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/convex-helpers/server/triggers.test.ts(5 hunks)packages/convex-helpers/server/triggers.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
When modifying complex TypeScript types, run
npm run typecheckin the repository root to ensure types are correct, rather than runningtscmanually
Files:
packages/convex-helpers/server/triggers.tspackages/convex-helpers/server/triggers.test.ts
🪛 GitHub Check: Test and lint
packages/convex-helpers/server/triggers.test.ts
[warning] 16-16:
'describe' is defined but never used. Allowed unused vars must match /^_/u
🔇 Additional comments (5)
packages/convex-helpers/server/triggers.ts (1)
442-442: LGTM! This fix correctly addresses the issue.The nullish coalescing operator (
?? []) ensures that when no triggers are registered for a table, the code iterates over an empty array instead ofundefined, preventing the "not iterable" error reported in issue #876.packages/convex-helpers/server/triggers.test.ts (4)
36-38: LGTM!The
userCounttable schema is correctly defined to support the denormalized counter trigger.
77-89: LGTM!The denormalized counter trigger correctly maintains a running count of users. The use of explicit table IDs in the patch operations (
ctx.db.patch("userCount", countId, ...)) provides excellent test coverage for the fix in triggers.ts.
126-141: LGTM!These mutations provide comprehensive test coverage for the bug fix. Both
updateUser(usingpatchwith explicit table name) anddeleteUser(usingdeletewith explicit table name) exercise the exact code paths that were failing before the fix in triggers.ts.
189-224: LGTM! Excellent test coverage.This test comprehensively validates the fix by exercising create, update, and delete operations with explicit table IDs. The assertions verify that the denormalized counter is correctly maintained throughout the lifecycle, confirming that the "not iterable" error no longer occurs.
Fixes #876
Summary by CodeRabbit
New Features
Bug Fixes
Tests
✏️ Tip: You can customize this high-level summary in your review settings.