-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Add query-based on_conflict support for UPSERT operations #47
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
Extends the on_conflict implementation to support Ecto.Query-based
updates, allowing keyword list syntax like:
on_conflict: [set: [name: "value"], inc: [count: 1]]
Changes:
- Add on_conflict pattern for %Ecto.Query{} in connection.ex
- Add update_all_for_on_conflict/1 helper for SQL generation
- Add 3 new tests for query-based on_conflict
- Document UPSERT operations in AGENTS.md and CHANGELOG.md
Closes el-ndz
WalkthroughThis pull request adds support for query-based UPSERT operations in the LibSQL adapter, enabling INSERT ... ON CONFLICT ... DO UPDATE with dynamic field updates via Ecto queries. The changes include documentation, implementation of a query-to-update-set converter, and test coverage for set, increment, and error scenarios. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (4)
🧰 Additional context used📓 Path-based instructions (8)**/*.{ex,exs,rs,md}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
{AGENTS.md,CHANGELOG.md,README.md,ECTO_MIGRATION_GUIDE.md,RUST_ERROR_HANDLING.md,TESTING.md}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
AGENTS.md📄 CodeRabbit inference engine (AGENT.md)
Files:
**/*.ex📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.{ex,exs,rs}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
**/*.{ex,exs}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
{migrations/**/*.exs,lib/ecto/adapters/libsql/connection.ex}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
test/**/*.exs📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧠 Learnings (15)📚 Learning: 2025-12-31T04:34:12.798ZApplied to files:
📚 Learning: 2025-12-30T11:31:53.999ZApplied to files:
📚 Learning: 2025-12-30T11:31:53.999ZApplied to files:
📚 Learning: 2025-12-30T11:31:53.999ZApplied to files:
📚 Learning: 2025-12-30T11:31:53.999ZApplied to files:
📚 Learning: 2025-12-31T04:34:12.798ZApplied to files:
📚 Learning: 2025-12-30T11:31:53.999ZApplied to files:
📚 Learning: 2025-12-31T04:34:12.798ZApplied to files:
📚 Learning: 2025-12-30T11:31:53.999ZApplied to files:
📚 Learning: 2025-12-30T11:31:53.999ZApplied to files:
📚 Learning: 2025-12-31T04:34:12.798ZApplied to files:
📚 Learning: 2025-12-31T04:34:12.798ZApplied to files:
📚 Learning: 2025-12-30T11:31:53.999ZApplied to files:
📚 Learning: 2025-12-31T04:34:12.798ZApplied to files:
📚 Learning: 2025-12-31T04:34:12.798ZApplied to files:
🧬 Code graph analysis (1)test/ecto_connection_test.exs (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
🔇 Additional comments (7)
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 |
Summary
on_conflictimplementation to supportEcto.Query-based updates:nothing,:replace_all,{:replace, fields}) was already implementedChanges
on_conflictpattern matching for%Ecto.Query{}inconnection.exupdate_all_for_on_conflict/1helper function for SQL generationAGENTS.mdwith examplesCHANGELOG.mdwith new featureExample Usage
Test Plan
Closes beads issue: el-ndz
Summary by CodeRabbit
Release Notes
New Features
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.