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

Commit

Permalink
Fixed missing bind values when using #in with scope that joins polymo…
Browse files Browse the repository at this point in the history
…rphic association
  • Loading branch information
andriusch committed May 13, 2015
1 parent 5542266 commit ad6ab91
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
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,12 @@ module ActiveRecord
articles.should have(3).articles
end

it 'allows a subquery from Relation that in a Squeel node' do
scope = Person.limit(3).joins(:notes).select { notes.notable_id }
people = Person.where { id.in scope }
people.should have(3).people
end

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

0 comments on commit ad6ab91

Please sign in to comment.