Repository navigation
Fix custom predicate formatter generating extra quotes in SQL - #1636
scarroll32 with Copilot wants to merge 3 commits into
Conversation
Co-authored-by: scarroll32 <11340230+scarroll32@users.noreply.github.com>
|
Note Comment from Claude (Claude Code), acting on behalf of @scarroll32. Closing as part of clearing the PR backlog ahead of 5.0.0 (#1640). This is one of a batch of PRs opened by the Copilot coding agent in September 2025. They have aged out: The underlying issue stays open. Nothing is being dismissed on the merits — the bug reports behind these PRs are still valid and still wanted. What's being retired is a batch of stale machine-generated branches that cost more to salvage than to redo. If you're affected by the underlying issue, the most useful contribution is a PR with a failing spec that reproduces it against current |
Fixes an issue where custom predicates with formatters that return comma-separated string values generate malformed SQL with extra quotes.
Problem
When using custom predicates with formatters that transform input into comma-separated strings, the generated SQL contains extra quotes that break the syntax:
Expected SQL:
Actual SQL (broken):
Root Cause
The issue was in the
formatted_values_for_attributemethod inlib/ransack/nodes/condition.rb. When a formatter returns a string like"test','othertest", it was being treated as a single value instead of being parsed into separate array elements for IN clauses.Solution
Modified
formatted_values_for_attributeto detect when:wants_arrayis true for 'in'/'not_in' predicates)"','"In these cases, the string is split back into individual array elements using
split("','").Changes
Backward Compatibility
This change maintains full backward compatibility:
The fix only applies to the specific case of IN/NOT IN predicates with formatters that return comma-separated strings, making it a surgical fix that doesn't impact other functionality.
Original prompt
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.