Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 24, 2025

  • Analyzed the repository structure and identified the OR modifier issue
  • Examined the code flow for parameter processing in Search#build and Grouping#build
  • Confirmed that 'm' parameter should be handled by the existing code structure
  • Added failing tests to reproduce the exact issue described
  • Implemented fix for top-level OR modifier issue
  • Added comprehensive tests to validate the fix and ensure no regressions
  • Final validation and cleanup complete

Summary

Issue Fixed:
The reported issue where ransack(m: 'or', id_eq: "12", name_contains: "12").result generated an AND query instead of an OR query has been resolved.

Root Cause Identified:
The Search#build method was not properly handling the top-level m parameter. While the documentation indicated this should work, the existing logic had a gap in processing the combinator parameter at the top level (as opposed to within sub-groupings).

Minimal Fix Implemented:

elsif key.to_s == 'm'
  # Handle combinator (m) parameter explicitly to ensure it works at top level
  base.combinator = value.to_s

Key Benefits:

  • Surgical change: Only 3 lines of code added
  • No breaking changes: Existing functionality preserved
  • Comprehensive testing: 6 new tests covering edge cases and regression prevention
  • Consistent behavior: Top-level OR now works exactly like documented

Tests Added:

  1. Basic OR functionality test
  2. Exact issue reproduction test (id_eq + name_contains)
  3. Symbol value handling test
  4. Default AND behavior verification
  5. Non-interference with existing grouping functionality
  6. Complex combination scenarios (top-level OR + sub-groupings)

Expected User Impact:
Users can now use ransack(m: 'or', field1: value1, field2: value2) at the top level and get OR queries as documented, matching the expected behavior described in the issue.


Additional instructions:

please check if this is covered by existing tests and if it is a real issue

Fixes #1148


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits September 24, 2025 15:13
Co-authored-by: scarroll32 <11340230+scarroll32@users.noreply.github.com>
Co-authored-by: scarroll32 <11340230+scarroll32@users.noreply.github.com>
Co-authored-by: scarroll32 <11340230+scarroll32@users.noreply.github.com>
Copilot stopped work on behalf of scarroll32 due to an error September 24, 2025 16:05
@Copilot Copilot AI requested a review from scarroll32 September 24, 2025 16:05
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.

modifier "or" not work correct
2 participants