Skip to content

Conversation

@ocean
Copy link
Owner

@ocean ocean commented Jan 27, 2026

Hopefully a real fix for #63 this time.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed IN clause handling to properly process wrapped query values, preventing datatype mismatch errors and ensuring correct result sets.
  • Tests

    • Added test case for IN clause functionality with literal word lists.
  • Documentation

    • Updated changelog with details on the IN clause fix.

✏️ Tip: You can customize this high-level summary in your review settings.

ocean and others added 3 commits January 27, 2026 17:52
…from oban)

- Add catch-all expr clause for IN with non-list right side
- Extract list values from Ecto.Query.Tagged structs before generating IN clause
- Fall back to JSON_EACH for pre-encoded JSON arrays
- Fixes issue #63: Oban job state queries using ~w() sigil now work correctly

Amp-Thread-ID: https://ampcode.com/threads/T-019bfe38-44f9-74fc-b369-9b0ab4ee93e8
Co-authored-by: Amp <amp@ampcode.com>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 27, 2026

Walkthrough

This pull request fixes IN clause handling for Ecto.Query.Tagged structs in the libSQL adapter. It adds a new catch-all clause to unwrap Tagged values before generating IN clauses, includes a corresponding test case, updates the changelog, and configures two new MCP permissions.

Changes

Cohort / File(s) Summary
Configuration Changes
.claude/settings.local.json
Added two new allowed permissions: mcp__acp__Bash and mcp__acp__Edit in the permissions allow array.
Documentation
CHANGELOG.md
Added Unreleased section with Fixed entry documenting the resolution of IN clause issues when used with Ecto.Query.Tagged structs.
Core Implementation & Test
lib/ecto/adapters/libsql/connection.ex, test/issue_63_in_clause_test.exs
Added a new catch-all clause to handle IN expressions where the right-hand side is non-list, unwrapping Ecto.Query.Tagged values and falling back to JSON_EACH approach for complex types. Added corresponding test case verifying IN clause behaviour with literal word lists wrapped as Tagged values.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Poem

A Tagged box was causing strife,
IN clauses couldn't find their way,
But clever unwrapping saved the day,
Now queries hop along with life! 🐰
No more datatype dismay! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title clearly and specifically summarises the main change: addressing datatype issues with lists in IN clauses, which aligns with the core fix implemented across the codebase changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch list-datatype-fixes

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 and usage tips.

@ocean
Copy link
Owner Author

ocean commented Jan 27, 2026

@CodeRabbit review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 27, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@ocean ocean merged commit 3946843 into main Jan 27, 2026
14 checks passed
@ocean ocean deleted the list-datatype-fixes branch January 27, 2026 07:51
ocean added a commit that referenced this pull request Jan 28, 2026
…67

Adds in_expression_comprehensive_test.exs to catch regressions in:

1. Issue #63: JSON encoding of list parameters in IN clauses
   - Simple list parameters should expand to individual placeholders
   - ~w() sigils should be handled via %Ecto.Query.Tagged{} detection

2. PR #66: Subqueries in IN expressions (Oban pattern)
   - WHERE id IN (SELECT ...) should generate proper SQL subquery
   - Before fix: incorrectly wrapped in JSON_EACH() causing malformed JSON error
   - After fix: generates inline subquery with correct aliases

3. PR #67: Tagged struct and type-wrapped expressions
   - Post-planning %Ecto.Query.Tagged{} nodes must be handled
   - Type-wrapped fragments should not fall through to catch-all '?' placeholder
   - Before fix: parameter count mismatch with Hrana/Turso
   - After fix: correct parameter count and proper type handling

Tests include:
- Basic list parameter expansion
- Empty lists and single-element lists
- ~w() sigil handling (Oban Lite pattern)
- Multiple IN clauses combined
- Subqueries with WHERE, SELECT, complex filters
- Type-cast expressions
- Integration tests combining multiple patterns

All 15 tests pass with the fixes in place.

Relates to: #63, PR #65, PR #66, PR #67
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.

2 participants