mirror of
https://github.com/activerecord-hackery/ransack.git
synced 2022-11-09 13:47:45 -05:00
Merge pull request #1128 from activerecord-hackery/revert-1122-fix_polymorphic_joins
Revert "Fixes polymorphic joins."
This commit is contained in:
commit
c08c11595c
2 changed files with 6 additions and 19 deletions
|
@ -1,20 +1,11 @@
|
|||
module Polyamorous
|
||||
module ReflectionExtensions
|
||||
if ActiveRecord.version > ::Gem::Version.new('5.2.3')
|
||||
def join_scope(table, foreign_table, foreign_klass)
|
||||
if respond_to?(:polymorphic?) && polymorphic?
|
||||
super.where!(foreign_table[foreign_type].eq(klass.name))
|
||||
else
|
||||
super
|
||||
end
|
||||
end
|
||||
else
|
||||
def build_join_constraint(table, foreign_table)
|
||||
if polymorphic?
|
||||
super.and(foreign_table[foreign_type].eq(klass.name))
|
||||
else
|
||||
super
|
||||
end
|
||||
def build_join_constraint(table, foreign_table)
|
||||
if polymorphic?
|
||||
super(table, foreign_table)
|
||||
.and(foreign_table[foreign_type].eq(klass.name))
|
||||
else
|
||||
super(table, foreign_table)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -257,9 +257,6 @@ module Ransack
|
|||
let(:children_people_name_field) {
|
||||
"#{quote_table_name("children_people")}.#{quote_column_name("name")}"
|
||||
}
|
||||
let(:notable_type_field) {
|
||||
"#{quote_table_name("notes")}.#{quote_column_name("notable_type")}"
|
||||
}
|
||||
it 'evaluates conditions contextually' do
|
||||
s = Search.new(Person, children_name_eq: 'Ernie')
|
||||
expect(s.result).to be_an ActiveRecord::Relation
|
||||
|
@ -331,7 +328,6 @@ module Ransack
|
|||
s = Search.new(Note, notable_of_Person_type_name_eq: 'Ernie').result
|
||||
expect(s).to be_an ActiveRecord::Relation
|
||||
expect(s.to_sql).to match /#{people_name_field} = 'Ernie'/
|
||||
expect(s.to_sql).to match /#{notable_type_field} = 'Person'/
|
||||
end
|
||||
|
||||
it 'evaluates nested conditions' do
|
||||
|
|
Loading…
Reference in a new issue