Skip to content
This repository has been archived by the owner on Mar 30, 2022. It is now read-only.

Fixed missing bind values when using #in with scope that joins polymorphic association #380

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def build_where(opts, other = [])
preprocess_attrs_with_ar(attributes)
when Squeel::Nodes::Node
arg.grep(::ActiveRecord::Relation) do |rel|
self.bind_values += rel.bind_values
self.bind_values += rel.arel.bind_values + rel.bind_values
end
arg
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,13 @@ module ActiveRecord
articles.should have(3).articles
end

it 'allows a subquery from Relation that in a Squeel node' do
names = [Person.first.name, Person.last.name]
scope = Person.where(name: names).joins(:notes).select { notes.notable_id }
people = Person.where { id.in scope }
people.should eq([Person.first, Person.last])
end

it 'is backwards-compatible with "where.not"' do
if activerecord_version_at_least '4.0.0'
name = Person.first.name
Expand Down