scoped_search
scoped_search copied to clipboard
undefined method `join_keys' for class `ActiveRecord::Reflection::HasManyReflection' - ActiveRecord 6.1
ActiveRecord::Reflection::HasManyReflection.join_keys
has been removed and replaced with join_primary_key
and join_foreign_key
.
To recreate it, perform a search on a has_many through relationship. This is a cut down version of my scenario
class Job < ApplicationRecord
has_many :job_locations, dependent: :destroy
has_many :locations, through: :job_locations
scoped_search relation: :locations, on: :street_number
#this search will raise an exception
Job.search_for('street_number = 1')
As a workaround, I've monkey patched ScopedSearch::QueryBuilder.has_many_through_join
. See lines 12-17 of this gist
Version info: Scoped Search: 4.1.9 ActiveRecord: 6.1 DB: MySQL 5.7 Ruby: 2.7.2
@stevequinlan Excellent workaround. Thank you. What do you think about adding those changes as a PR? If you don't have time, I'd be happy to do it. Just trying to make bringing this change into the project as easy as possible.
I don't have the time, but if you're happy to do it, please do.
This issue is already represented in the tests.
Finished in 17.77 seconds (files took 0.48395 seconds to load)
771 examples, 57 failures
Failed examples:
rspec './spec/integration/nested_has_many_through_querying_spec.rb[1:1:1]' # ScopedSearch using a mysql database quering on associations which are behind multiple has-many-through associations allows searching on has many through has many
rspec './spec/integration/nested_has_many_through_querying_spec.rb[1:1:2]' # ScopedSearch using a mysql database quering on associations which are behind multiple has-many-through associations allows searching on has many through has one through has many
rspec './spec/integration/nested_has_many_through_querying_spec.rb[2:1:1]' # ScopedSearch using a postgresql database quering on associations which are behind multiple has-many-through associations allows searching on has many through has many
rspec './spec/integration/nested_has_many_through_querying_spec.rb[2:1:2]' # ScopedSearch using a postgresql database quering on associations which are behind multiple has-many-through associations allows searching on has many through has one through has many
rspec './spec/integration/nested_has_many_through_querying_spec.rb[3:1:1]' # ScopedSearch using a sqlite database quering on associations which are behind multiple has-many-through associations allows searching on has many through has many
rspec './spec/integration/nested_has_many_through_querying_spec.rb[3:1:2]' # ScopedSearch using a sqlite database quering on associations which are behind multiple has-many-through associations allows searching on has many through has one through has many
rspec './spec/integration/relation_querying_spec.rb[1:6:1]' # ScopedSearch using a mysql database querying a :has_many => :through relation should find the two records that are related to a baz record
rspec './spec/integration/relation_querying_spec.rb[1:6:2]' # ScopedSearch using a mysql database querying a :has_many => :through relation should find the two records that are related to a baz record
rspec './spec/integration/relation_querying_spec.rb[1:7:1]' # ScopedSearch using a mysql database querying a :has_many => :through many relation should find the three records that are related to a baz record
rspec './spec/integration/relation_querying_spec.rb[1:7:2]' # ScopedSearch using a mysql database querying a :has_many => :through many relation should find no records that are related to a baz record
rspec './spec/integration/relation_querying_spec.rb[1:8:1]' # ScopedSearch using a mysql database querying a :has_many => :through :polymorphic relation should find the two records that are related to a tag that contains foo record
rspec './spec/integration/relation_querying_spec.rb[1:8:2]' # ScopedSearch using a mysql database querying a :has_many => :through :polymorphic relation should find the only record that is related to a tag
rspec './spec/integration/relation_querying_spec.rb[1:8:3]' # ScopedSearch using a mysql database querying a :has_many => :through :polymorphic relation should find one records that is related to both tags
rspec './spec/integration/relation_querying_spec.rb[1:8:4]' # ScopedSearch using a mysql database querying a :has_many => :through :polymorphic relation should find the two tags that are related to a dog record
rspec './spec/integration/relation_querying_spec.rb[1:8:5]' # ScopedSearch using a mysql database querying a :has_many => :through :polymorphic relation should find the 3 tags that are related to dogs record
rspec './spec/integration/relation_querying_spec.rb[1:9:1]' # ScopedSearch using a mysql database querying a :has_many => :through relation with alternate name should find the two records that are related to a paz record
rspec './spec/integration/relation_querying_spec.rb[1:9:2]' # ScopedSearch using a mysql database querying a :has_many => :through relation with alternate name should find the one record that is related to two paz records
rspec './spec/integration/relation_querying_spec.rb[1:10:1]' # ScopedSearch using a mysql database querying a :has_many => :through relation with same name on target class with custom condition should find the one record that is related based on forward groups relation
rspec './spec/integration/relation_querying_spec.rb[1:11:1]' # ScopedSearch using a mysql database querying a :has_many => :through relation with modules should find the two records that are related to a baz record
rspec './spec/integration/relation_querying_spec.rb[1:11:2]' # ScopedSearch using a mysql database querying a :has_many => :through relation with modules should find the one record that is related to two baz records
rspec './spec/integration/relation_querying_spec.rb[1:12:1]' # ScopedSearch using a mysql database querying a :has_many => :through with polymorphism should find the records based on location id
rspec './spec/integration/relation_querying_spec.rb[1:12:2]' # ScopedSearch using a mysql database querying a :has_many => :through with polymorphism should find the records based on organization id
rspec './spec/integration/relation_querying_spec.rb[1:13:1]' # ScopedSearch using a mysql database querying with multiple :has_many => :through and polymorphism should find the usermat when searching on usergroup
rspec './spec/integration/relation_querying_spec.rb[2:6:1]' # ScopedSearch using a postgresql database querying a :has_many => :through relation should find the two records that are related to a baz record
rspec './spec/integration/relation_querying_spec.rb[2:6:2]' # ScopedSearch using a postgresql database querying a :has_many => :through relation should find the two records that are related to a baz record
rspec './spec/integration/relation_querying_spec.rb[2:7:1]' # ScopedSearch using a postgresql database querying a :has_many => :through many relation should find the three records that are related to a baz record
rspec './spec/integration/relation_querying_spec.rb[2:7:2]' # ScopedSearch using a postgresql database querying a :has_many => :through many relation should find no records that are related to a baz record
rspec './spec/integration/relation_querying_spec.rb[2:8:1]' # ScopedSearch using a postgresql database querying a :has_many => :through :polymorphic relation should find the two records that are related to a tag that contains foo record
rspec './spec/integration/relation_querying_spec.rb[2:8:2]' # ScopedSearch using a postgresql database querying a :has_many => :through :polymorphic relation should find the only record that is related to a tag
rspec './spec/integration/relation_querying_spec.rb[2:8:3]' # ScopedSearch using a postgresql database querying a :has_many => :through :polymorphic relation should find one records that is related to both tags
rspec './spec/integration/relation_querying_spec.rb[2:8:4]' # ScopedSearch using a postgresql database querying a :has_many => :through :polymorphic relation should find the two tags that are related to a dog record
rspec './spec/integration/relation_querying_spec.rb[2:8:5]' # ScopedSearch using a postgresql database querying a :has_many => :through :polymorphic relation should find the 3 tags that are related to dogs record
rspec './spec/integration/relation_querying_spec.rb[2:9:1]' # ScopedSearch using a postgresql database querying a :has_many => :through relation with alternate name should find the two records that are related to a paz record
rspec './spec/integration/relation_querying_spec.rb[2:9:2]' # ScopedSearch using a postgresql database querying a :has_many => :through relation with alternate name should find the one record that is related to two paz records
rspec './spec/integration/relation_querying_spec.rb[2:10:1]' # ScopedSearch using a postgresql database querying a :has_many => :through relation with same name on target class with custom condition should find the one record that is related based on forward groups relation
rspec './spec/integration/relation_querying_spec.rb[2:11:1]' # ScopedSearch using a postgresql database querying a :has_many => :through relation with modules should find the two records that are related to a baz record
rspec './spec/integration/relation_querying_spec.rb[2:11:2]' # ScopedSearch using a postgresql database querying a :has_many => :through relation with modules should find the one record that is related to two baz records
rspec './spec/integration/relation_querying_spec.rb[2:12:1]' # ScopedSearch using a postgresql database querying a :has_many => :through with polymorphism should find the records based on location id
rspec './spec/integration/relation_querying_spec.rb[2:12:2]' # ScopedSearch using a postgresql database querying a :has_many => :through with polymorphism should find the records based on organization id
rspec './spec/integration/relation_querying_spec.rb[2:13:1]' # ScopedSearch using a postgresql database querying with multiple :has_many => :through and polymorphism should find the usermat when searching on usergroup
rspec './spec/integration/relation_querying_spec.rb[3:6:1]' # ScopedSearch using a sqlite database querying a :has_many => :through relation should find the two records that are related to a baz record
rspec './spec/integration/relation_querying_spec.rb[3:6:2]' # ScopedSearch using a sqlite database querying a :has_many => :through relation should find the two records that are related to a baz record
rspec './spec/integration/relation_querying_spec.rb[3:7:1]' # ScopedSearch using a sqlite database querying a :has_many => :through many relation should find the three records that are related to a baz record
rspec './spec/integration/relation_querying_spec.rb[3:7:2]' # ScopedSearch using a sqlite database querying a :has_many => :through many relation should find no records that are related to a baz record
rspec './spec/integration/relation_querying_spec.rb[3:8:1]' # ScopedSearch using a sqlite database querying a :has_many => :through :polymorphic relation should find the two records that are related to a tag that contains foo record
rspec './spec/integration/relation_querying_spec.rb[3:8:2]' # ScopedSearch using a sqlite database querying a :has_many => :through :polymorphic relation should find the only record that is related to a tag
rspec './spec/integration/relation_querying_spec.rb[3:8:3]' # ScopedSearch using a sqlite database querying a :has_many => :through :polymorphic relation should find one records that is related to both tags
rspec './spec/integration/relation_querying_spec.rb[3:8:4]' # ScopedSearch using a sqlite database querying a :has_many => :through :polymorphic relation should find the two tags that are related to a dog record
rspec './spec/integration/relation_querying_spec.rb[3:8:5]' # ScopedSearch using a sqlite database querying a :has_many => :through :polymorphic relation should find the 3 tags that are related to dogs record
rspec './spec/integration/relation_querying_spec.rb[3:9:1]' # ScopedSearch using a sqlite database querying a :has_many => :through relation with alternate name should find the two records that are related to a paz record
rspec './spec/integration/relation_querying_spec.rb[3:9:2]' # ScopedSearch using a sqlite database querying a :has_many => :through relation with alternate name should find the one record that is related to two paz records
rspec './spec/integration/relation_querying_spec.rb[3:10:1]' # ScopedSearch using a sqlite database querying a :has_many => :through relation with same name on target class with custom condition should find the one record that is related based on forward groups relation
rspec './spec/integration/relation_querying_spec.rb[3:11:1]' # ScopedSearch using a sqlite database querying a :has_many => :through relation with modules should find the two records that are related to a baz record
rspec './spec/integration/relation_querying_spec.rb[3:11:2]' # ScopedSearch using a sqlite database querying a :has_many => :through relation with modules should find the one record that is related to two baz records
rspec './spec/integration/relation_querying_spec.rb[3:12:1]' # ScopedSearch using a sqlite database querying a :has_many => :through with polymorphism should find the records based on location id
rspec './spec/integration/relation_querying_spec.rb[3:12:2]' # ScopedSearch using a sqlite database querying a :has_many => :through with polymorphism should find the records based on organization id
rspec './spec/integration/relation_querying_spec.rb[3:13:1]' # ScopedSearch using a sqlite database querying with multiple :has_many => :through and polymorphism should find the usermat when searching on usergroup
@andynu thanks! @stevequinlan Is there a chance to merge fix?