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

Commit ad6ab91

Browse files
committed
Fixed missing bind values when using #in with scope that joins polymorphic association
1 parent 5542266 commit ad6ab91

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/squeel/adapters/active_record/4.1/relation_extensions.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ def build_where(opts, other = [])
197197
preprocess_attrs_with_ar(attributes)
198198
when Squeel::Nodes::Node
199199
arg.grep(::ActiveRecord::Relation) do |rel|
200-
self.bind_values += rel.bind_values
200+
self.bind_values += rel.arel.bind_values + rel.bind_values
201201
end
202202
arg
203203
else

spec/squeel/adapters/active_record/relation_extensions_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,12 @@ module ActiveRecord
632632
articles.should have(3).articles
633633
end
634634

635+
it 'allows a subquery from Relation that in a Squeel node' do
636+
scope = Person.limit(3).joins(:notes).select { notes.notable_id }
637+
people = Person.where { id.in scope }
638+
people.should have(3).people
639+
end
640+
635641
it 'is backwards-compatible with "where.not"' do
636642
if activerecord_version_at_least '4.0.0'
637643
name = Person.first.name

0 commit comments

Comments
 (0)