Repository navigation
Add failing test for single filter with multiple joins using wrong association alias - #1628
scarroll32 with Copilot wants to merge 3 commits into
Conversation
…sociation alias 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 |
This PR adds a failing test to reproduce the bug where a single filter with multiple joins to the same table uses the wrong association alias.
Issue Description
When using Ransack with multiple joins to the same table and applying a filter to only one of the joined associations, the generated SQL uses the wrong table alias in the WHERE clause.
Problem Example
Consider this query:
Current (incorrect) behavior:
Expected (correct) behavior:
What This PR Does
This PR adds a failing test case that demonstrates the bug. The test:
Recommendation.joins(:person, :target_person).ransack({target_person_name_eq: 'Test'})Impact
This bug affects queries where:
The bug can cause incorrect query results by filtering on the wrong table alias.
Note
This PR intentionally does not include a fix - it only adds the failing test case to reproduce the issue and serve as a specification for the expected behavior.
Original prompt
Fixes #1554
💡 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.