Git Product home page Git Product logo

polyamorous's People

Contributors

bigxiang avatar codegoalie avatar ernie avatar gregmolnar avatar huoxito avatar irmiller22 avatar jerhinesmith avatar johnnyshields avatar jonatack avatar radar avatar scarroll32 avatar spectator avatar syndbg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

polyamorous's Issues

Documentation?

I totally understand that this is a private API, and I understand why polyamorous isn't currently documented. Though, it would be really nice to have a tiny bit of documentation about how it works.

It was really tricky and required a lot of digging to pull polyamorous into baby_squeel for this reason.

What about BabySqueel?

Polyamorous is merged into Ransack since Squeel and MetaSearch is not maintained anymore

the idea that is unstated but apparently implied is that there is no longer any value in maintaining this as an independent gem, because nothing at all is using it anymore except Ransack. But the problem is that that's not true. In the very least BabySqueel is using it. Would you consider keeping polyamorous separate going as a separate gem?

#left_outer_joins in Rails 5 returns INNER JOIN

#make_left_outer_joins in activerecord/lib/active_record/associations/join_dependency.rb overrides join_type to Arel::Nodes::OuterJoin (rails/rails@e038975), whereas #make_polyamorous_left_outer_joins in activerecord_5.0_ruby_2/join_dependency.rb does the following:

join_type = child.join_type || Arel::Nodes::OuterJoin

When doing a #left_outer_joins, child comes in with the join_type Arel::Nodes::InnerJoin, which as a result when polyamorous is installed, #left_outer_joins in ActiveRecord 5 always perform an INNER JOIN.

Changed interface for rails 4.1 JoinDependencyExtensions.build_with_polymorphism

Hi, I was trying to play with rails 4.1 and required polyamorous from master branch. However, whenever I do a FactoryGirl.create(:something) I get an error like this:

ArgumentError: wrong number of arguments (3 for 2)
from /Users/shaomengzhang/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/bundler/gems/polyamorous-3d45f4c9219b/lib/polyamorous/activerecord_4.1/join_dependency.rb:18:in `build_with_polymorphism'

I noticed the interface for that method has indeed been changed since rails 3-4.0 from taking 3 arguments to 2:
def build_with_polymorphism(associations, base_klass)
Or is this something that need to be patched in FactoryGirl or somewhere else? Thanks!


UPDATE:
Looks like Squeel was calling the methods with 3 arguments.
Here is the stack trace:

Exception: ArgumentError: wrong number of arguments (3 for 2)
--
0: /Users/shaomengzhang/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/bundler/gems/polyamorous-3d45f4c9219b/lib/polyamorous/activerecord_4.1/join_dependency.rb:18:in `build_with_polymorphism'
1: /Users/shaomengzhang/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/squeel-1.1.1/lib/squeel/adapters/active_record/join_dependency_extensions.rb:29:in `build_with_squeel'
2: /Users/shaomengzhang/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/activerecord-4.1.0.rc1/lib/active_record/associations/join_dependency.rb:99:in `initialize'
3: /Users/shaomengzhang/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/activerecord-4.1.0.rc1/lib/active_record/relation/finder_methods.rb:346:in `new'
4: /Users/shaomengzhang/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/activerecord-4.1.0.rc1/lib/active_record/relation/finder_methods.rb:346:in `construct_join_dependency'
5: /Users/shaomengzhang/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/activerecord-4.1.0.rc1/lib/active_record/relation/finder_methods.rb:286:in `exists?'
6: /Users/shaomengzhang/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/activerecord-4.1.0.rc1/lib/active_record/validations/uniqueness.rb:24:in `validate_each'
7: /Users/shaomengzhang/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/activemodel-4.1.0.rc1/lib/active_model/validator.rb:167:in `block in validate'
8: /Users/shaomengzhang/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/activemodel-4.1.0.rc1/lib/active_model/validator.rb:164:in `each'
9: /Users/shaomengzhang/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/activemodel-4.1.0.rc1/lib/active_model/validator.rb:164:in `validate'

error running in rails 5.2.2

version:

rails 5.2.2, ruby 2.4.1.

errors:

when I run rake db:create, error raise:

cannot load such file -- polyamorous/activerecord_5.2.2_ruby_2/join_association (LoadError)

I have found that the issue #28 is very similar to this one. I have also reviewed the PR add support to rails5.2 made by @gssbzn , he has fixed it. so I have no idea why I got the error in rails 5.2.2. It is possible that a new PR needed to support to rails 5.2.2?

Problems with Rails 5.2.2

I updated to Rails 5.2.2 and got this error
LoadError: cannot load such file -- polyamorous/activerecord_5.2.2_ruby_2/join_association

Error running in Rails 5.1.2

'bundle install' works with latest polyamorous gem, but running gives following error:

mattlindsey@MATTs-MBP WebsiteOne (1737_rails_5) $ bundle exec cucumber features
[Coveralls] Using SimpleCov's 'rails' settings.
There was an error while trying to load the gem 'polyamorous'.
Gem Load Error is: undefined method `alias_method_chain' for ActiveRecord::Associations::JoinDependency:Class
Did you mean?  alias_method
Backtrace for gem load error is:
/Users/mattlindsey/.rvm/gems/ruby-2.3.1/gems/polyamorous-1.2.0/lib/polyamorous/activerecord_3_and_4.0_ruby_1.9/join_dependency.rb:6:in `block in included'
/Users/mattlindsey/.rvm/gems/ruby-2.3.1/gems/polyamorous-1.2.0/lib/polyamorous/activerecord_3_and_4.0_ruby_1.9/join_dependency.rb:5:in `class_eval'
/Users/mattlindsey/.rvm/gems/ruby-2.3.1/gems/polyamorous-1.2.0/lib/polyamorous/activerecord_3_and_4.0_ruby_1.9/join_dependency.rb:5:in `included'
/Users/mattlindsey/.rvm/gems/ruby-2.3.1/gems/polyamorous-1.2.0/lib/polyamorous.rb:51:in `include'
/Users/mattlindsey/.rvm/gems/ruby-2.3.1/gems/polyamorous-1.2.0/lib/polyamorous.rb:51:in `<top (required)>'
/Users/mattlindsey/.rvm/gems/ruby-2.3.1/gems/bundler-1.15.2/lib/bundler/runtime.rb:82:in `require'
/Users/mattlindsey/.rvm/gems/ruby-2.3.1/gems/bundler-1.15.2/lib/bundler/runtime.rb:82:in `block (2 levels) in require'
/Users/mattlindsey/.rvm/gems/ruby-2.3.1/gems/bundler-1.15.2/lib/bundler/runtime.rb:77:in `each'
/Users/mattlindsey/.rvm/gems/ruby-2.3.1/gems/bundler-1.15.2/lib/bundler/runtime.rb:77:in `block in require'
/Users/mattlindsey/.rvm/gems/ruby-2.3.1/gems/bundler-1.15.2/lib/bundler/runtime.rb:66:in `each'
/Users/mattlindsey/.rvm/gems/ruby-2.3.1/gems/bundler-1.15.2/lib/bundler/runtime.rb:66:in `require'
/Users/mattlindsey/.rvm/gems/ruby-2.3.1/gems/bundler-1.15.2/lib/bundler.rb:108:in `require'
/Users/mattlindsey/Documents/github/WebsiteOne/config/application.rb:7:in `<top (required)>'
/Users/mattlindsey/Documents/github/WebsiteOne/config/environment.rb:2:in `require'
/Users/mattlindsey/Documents/github/WebsiteOne/config/environment.rb:2:in `<top (required)>'
/Users/mattlindsey/.rvm/gems/ruby-2.3.1/gems/cucumber-rails-1.5.0/lib/cucumber/rails.rb:7:in `require'
/Users/mattlindsey/.rvm/gems/ruby-2.3.1/gems/cucumber-rails-1.5.0/lib/cucumber/rails.rb:7:in `<top (required)>'
/Users/mattlindsey/Documents/github/WebsiteOne/features/support/env.rb:9:in `require'
/Users/mattlindsey/Documents/github/WebsiteOne/features/support/env.rb:9:in `<top (required)>'
/Users/mattlindsey/.rvm/gems/ruby-2.3.1/gems/cucumber-2.4.0/lib/cucumber/rb_support/rb_language.rb:96:in `load'
/Users/mattlindsey/.rvm/gems/ruby-2.3.1/gems/cucumber-2.4.0/lib/cucumber/rb_support/rb_language.rb:96:in `load_code_file'
/Users/mattlindsey/.rvm/gems/ruby-2.3.1/gems/cucumber-2.4.0/lib/cucumber/runtime/support_code.rb:142:in `load_file'
/Users/mattlindsey/.rvm/gems/ruby-2.3.1/gems/cucumber-2.4.0/lib/cucumber/runtime/support_code.rb:84:in `block in load_files!'
/Users/mattlindsey/.rvm/gems/ruby-2.3.1/gems/cucumber-2.4.0/lib/cucumber/runtime/support_code.rb:83:in `each'
/Users/mattlindsey/.rvm/gems/ruby-2.3.1/gems/cucumber-2.4.0/lib/cucumber/runtime/support_code.rb:83:in `load_files!'
/Users/mattlindsey/.rvm/gems/ruby-2.3.1/gems/cucumber-2.4.0/lib/cucumber/runtime.rb:253:in `load_step_definitions'
/Users/mattlindsey/.rvm/gems/ruby-2.3.1/gems/cucumber-2.4.0/lib/cucumber/runtime.rb:61:in `run!'
/Users/mattlindsey/.rvm/gems/ruby-2.3.1/gems/cucumber-2.4.0/lib/cucumber/cli/main.rb:32:in `execute!'
/Users/mattlindsey/.rvm/gems/ruby-2.3.1/gems/cucumber-2.4.0/bin/cucumber:8:in `<top (required)>'
/Users/mattlindsey/.rvm/gems/ruby-2.3.1/bin/cucumber:22:in `load'
/Users/mattlindsey/.rvm/gems/ruby-2.3.1/bin/cucumber:22:in `<main>'
/Users/mattlindsey/.rvm/gems/ruby-2.3.1/bin/ruby_executable_hooks:15:in `eval'
/Users/mattlindsey/.rvm/gems/ruby-2.3.1/bin/ruby_executable_hooks:15:in `<main>'
Bundler Error Backtrace:
 (Bundler::GemRequireError)
/Users/mattlindsey/.rvm/gems/ruby-2.3.1/gems/bundler-1.15.2/lib/bundler/runtime.rb:85:in `rescue in block (2 levels) in require'
/Users/mattlindsey/.rvm/gems/ruby-2.3.1/gems/bundler-1.15.2/lib/bundler/runtime.rb:81:in `block (2 levels) in require'
/Users/mattlindsey/.rvm/gems/ruby-2.3.1/gems/bundler-1.15.2/lib/bundler/runtime.rb:77:in `each'
/Users/mattlindsey/.rvm/gems/ruby-2.3.1/gems/bundler-1.15.2/lib/bundler/runtime.rb:77:in `block in require'
/Users/mattlindsey/.rvm/gems/ruby-2.3.1/gems/bundler-1.15.2/lib/bundler/runtime.rb:66:in `each'
/Users/mattlindsey/.rvm/gems/ruby-2.3.1/gems/bundler-1.15.2/lib/bundler/runtime.rb:66:in `require'
/Users/mattlindsey/.rvm/gems/ruby-2.3.1/gems/bundler-1.15.2/lib/bundler.rb:108:in `require'
/Users/mattlindsey/Documents/github/WebsiteOne/config/application.rb:7:in `<top (required)>'
/Users/mattlindsey/Documents/github/WebsiteOne/config/environment.rb:2:in `require'
/Users/mattlindsey/Documents/github/WebsiteOne/config/environment.rb:2:in `<top (required)>'
/Users/mattlindsey/.rvm/gems/ruby-2.3.1/gems/cucumber-rails-1.5.0/lib/cucumber/rails.rb:7:in `require'
/Users/mattlindsey/.rvm/gems/ruby-2.3.1/gems/cucumber-rails-1.5.0/lib/cucumber/rails.rb:7:in `<top (required)>'
/Users/mattlindsey/Documents/github/WebsiteOne/features/support/env.rb:9:in `require'
/Users/mattlindsey/Documents/github/WebsiteOne/features/support/env.rb:9:in `<top (required)>'
/Users/mattlindsey/.rvm/gems/ruby-2.3.1/gems/cucumber-2.4.0/lib/cucumber/rb_support/rb_language.rb:96:in `load'
/Users/mattlindsey/.rvm/gems/ruby-2.3.1/gems/cucumber-2.4.0/lib/cucumber/rb_support/rb_language.rb:96:in `load_code_file'
/Users/mattlindsey/.rvm/gems/ruby-2.3.1/gems/cucumber-2.4.0/lib/cucumber/runtime/support_code.rb:142:in `load_file'
/Users/mattlindsey/.rvm/gems/ruby-2.3.1/gems/cucumber-2.4.0/lib/cucumber/runtime/support_code.rb:84:in `block in load_files!'
/Users/mattlindsey/.rvm/gems/ruby-2.3.1/gems/cucumber-2.4.0/lib/cucumber/runtime/support_code.rb:83:in `each'
/Users/mattlindsey/.rvm/gems/ruby-2.3.1/gems/cucumber-2.4.0/lib/cucumber/runtime/support_code.rb:83:in `load_files!'
/Users/mattlindsey/.rvm/gems/ruby-2.3.1/gems/cucumber-2.4.0/lib/cucumber/runtime.rb:253:in `load_step_definitions'
/Users/mattlindsey/.rvm/gems/ruby-2.3.1/gems/cucumber-2.4.0/lib/cucumber/runtime.rb:61:in `run!'
/Users/mattlindsey/.rvm/gems/ruby-2.3.1/gems/cucumber-2.4.0/lib/cucumber/cli/main.rb:32:in `execute!'
/Users/mattlindsey/.rvm/gems/ruby-2.3.1/gems/cucumber-2.4.0/bin/cucumber:8:in `<top (required)>'
/Users/mattlindsey/.rvm/gems/ruby-2.3.1/bin/cucumber:22:in `load'
/Users/mattlindsey/.rvm/gems/ruby-2.3.1/bin/cucumber:22:in `<main>'
/Users/mattlindsey/.rvm/gems/ruby-2.3.1/bin/ruby_executable_hooks:15:in `eval'
/Users/mattlindsey/.rvm/gems/ruby-2.3.1/bin/ruby_executable_hooks:15:in `<main>'

Incompatible with Rails 5.2.1.rc1

It looks like JoinAssociation was changed from 5.2.0 to 5.2.1 so that its initializer only accepts two arguments instead of one:

rails/rails@15e3e9c#diff-7d2190f5cc2af538347085d7551fea1dR12

Which breaks here:

super(reflection, children, alias_tracker)

This leads to a stack trace like this:

ArgumentError: wrong number of arguments (given 3, expected 2)
/Users/user/.rvm/gems/ruby-2.5.1/gems/activerecord-5.2.1.rc1/lib/active_record/associations/join_dependency/join_association.rb:12:in `initialize'
/Users/user/.rvm/gems/ruby-2.5.1/gems/polyamorous-1.3.3/lib/polyamorous/activerecord_5.2_ruby_2/join_association.rb:19:in `initialize'
/Users/user/.rvm/gems/ruby-2.5.1/gems/polyamorous-1.3.3/lib/polyamorous/activerecord_5.2_ruby_2/join_dependency.rb:28:in `new'
/Users/user/.rvm/gems/ruby-2.5.1/gems/polyamorous-1.3.3/lib/polyamorous/activerecord_5.2_ruby_2/join_dependency.rb:28:in `block in build'
/Users/user/.rvm/gems/ruby-2.5.1/gems/polyamorous-1.3.3/lib/polyamorous/activerecord_5.2_ruby_2/join_dependency.rb:8:in `each'
/Users/user/.rvm/gems/ruby-2.5.1/gems/polyamorous-1.3.3/lib/polyamorous/activerecord_5.2_ruby_2/join_dependency.rb:8:in `map'
/Users/user/.rvm/gems/ruby-2.5.1/gems/polyamorous-1.3.3/lib/polyamorous/activerecord_5.2_ruby_2/join_dependency.rb:8:in `build'

ActiveRecord::EagerLoadPolymorphicError

I have following model and association

class User < ActiveRecord::Base
    has_many :pivots
    has_many :owned_attachments,
      through: :pivots, as: :asset,
      source: :asset, source_type: 'Attachment'
end

class Pivots
  belongs_to :asset, polymorphic: true
end

class Attachment
  belongs_to :entity, polymorphic: true
  has_one :pivot, as: :asset
end

When I do User.first.owned_attachments it raise following exception


 ActiveRecord::EagerLoadPolymorphicError:
       Cannot eagerly load the polymorphic association :entity
     # /home/kiprosh-g50/.rvm/gems/ruby-2.2.2@realvolve/gems/polyamorous-1.3.0/lib/polyamorous/activerecord_5.0_ruby_2/join_dependency.rb:23:in `block in build'
     # /home/kiprosh-g50/.rvm/gems/ruby-2.2.2@realvolve/gems/polyamorous-1.3.0/lib/polyamorous/activerecord_5.0_ruby_2/join_dependency.rb:9:in `each'
     # /home/kiprosh-g50/.rvm/gems/ruby-2.2.2@realvolve/gems/polyamorous-1.3.0/lib/polyamorous/activerecord_5.0_ruby_2/join_dependency.rb:9:in `map'
     # /home/kiprosh-g50/.rvm/gems/ruby-2.2.2@realvolve/gems/polyamorous-1.3.0/lib/polyamorous/activerecord_5.0_ruby_2/join_dependency.rb:9:in `build'
     # /home/kiprosh-g50/.rvm/gems/ruby-2.2.2@realvolve/gems/activerecord-4.2.5/lib/active_record/associations/join_dependency.rb:99:in `initialize'
     # /home/kiprosh-g50/.rvm/gems/ruby-2.2.2@realvolve/gems/activerecord-4.2.5/lib/active_record/relation/finder_methods.rb:364:in `new'
     # /home/kiprosh-g50/.rvm/gems/ruby-2.2.2@realvolve/gems/activerecord-4.2.5/lib/active_record/relation/finder_methods.rb:364:in `construct_join_dependency'
     # /home/kiprosh-g50/.rvm/gems/ruby-2.2.2@realvolve/gems/activerecord-4.2.5/lib/active_record/relation/finder_methods.rb:288:in `exists?'

Can anybody help.

Thanks

Usage

Can you please describe the usage/syntax.

How about some docs?

We noticed that our site is using this gem through some dependency, so I thought I'd look it up, which brought me here... where I'm learning nothing.

How about a couple lines of text to tell us what this gem actually does?

undefined method `polymorphic?

With the latest version of gem

  1) Account::ArticlesController As admin GET #index returns http success
     Failure/Error: = f.select :cities_id_in, City.joins(:articles).ordered.distinct.collect{|e| [e.name, e.id]}, {include_blank: 'Select City'}, class: 'form-control', style: 'width: 200px'
     
     ActionView::Template::Error:
       undefined method `polymorphic?' for #<ActiveRecord::Reflection::PolymorphicReflection:0x0000000015772d50>
     # /usr/local/rvm/gems/ruby-2.6.1/gems/polyamorous-2.3.0/lib/polyamorous/activerecord_5.2.0_ruby_2/reflection.rb:4:in `build_join_constraint'
     # /usr/local/rvm/gems/ruby-2.6.1/gems/polyamorous-2.3.0/lib/polyamorous/activerecord_5.2.1_ruby_2/join_dependency.rb:53:in `make_constraints'
     # /usr/local/rvm/gems/ruby-2.6.1/gems/polyamorous-2.3.0/lib/polyamorous/activerecord_5.2.1_ruby_2/join_dependency.rb:36:in `join_constraints'
     # ./app/views/account/articles/index.html.slim:26:in `collect'

Schema is:

City
  has_many :city_relations, dependent: :destroy
  has_many :articles, through: :city_relations, source: :relationable, source_type: 'Article'

class CityRelation
  belongs_to :city
  belongs_to :relationable, polymorphic: true

class Article
  has_many :city_relations, as: :relationable, dependent: :destroy
  has_many :cities, through: :city_relations

Failing `joins` on Rails 5.2.0.beta2

When using polyamorous with rails 5.2.0.beta2, I'm getting an ActiveRecord::StatementInvalid exception whenever I use a joins. Here's an example SQL statement that's getting generated:

SELECT COUNT(*) FROM INNER JOIN "comments" ON "comments"."post_id" = "posts"."id"

If you look, there's no table name specified between the FROM and the INNER JOIN.

I created a reproduction repo here, along with steps to reproduce:

https://github.com/jerhinesmith/rails5_bug

Not compatible with rails 5.2.1

Upgraded to 5.2.1 from 5.2.0 and I get this error:

ArgumentError: wrong number of arguments (given 3, expected 2)
from /Users/xxx/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/polyamorous-1.3.3/lib/polyamorous/activerecord_5.2_ruby_2/join_dependency.rb:58:in `join_constraints'

I've just found out this method really defines only 2 arguments

def join_constraints(outer_joins, join_type)

but new rails 5.2.1 defines it with 3 arguments:

def join_constraints(joins_to_add, join_type, alias_tracker)

Please see rails source code join_dependency.rb:79

Error running in Rails 5.1.2 - 3 argument initialze of JoinAssociation

I'm getting a different error running in Rails 5.1.2

Exception: ArgumentError: wrong number of arguments (given 3, expected 2)

  0: /Users/alex/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activerecord-5.2.1/lib/active_record/associations/join_dependency/join_association.rb:12:in `initialize'
  1: /Users/alex/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/polyamorous-1.3.3/lib/polyamorous/activerecord_5.2_ruby_2/join_association.rb:19:in `initialize'
  2: /Users/alex/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/polyamorous-1.3.3/lib/polyamorous/activerecord_5.2_ruby_2/join_dependency.rb:28:in `new'
  3: /Users/alex/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/polyamorous-1.3.3/lib/polyamorous/activerecord_5.2_ruby_2/join_dependency.rb:28:in `block in build'
  4: /Users/alex/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/polyamorous-1.3.3/lib/polyamorous/activerecord_5.2_ruby_2/join_dependency.rb:8:in `each'
  5: /Users/alex/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/polyamorous-1.3.3/lib/polyamorous/activerecord_5.2_ruby_2/join_dependency.rb:8:in `map'
...

Polyamorous is calling super(reflection, children, alias_tracker) but the 5.1.2 version of ActiveRecord::Associations::JoinDependency::JoinAssociation only takes two arguments to initialize.

At least i think that's the problem? It's a bit of a maze ๐Ÿ˜…

Let me know if I can provide any extra info ๐Ÿ’ž

Could someone nudge Squeel's depenedence of polyamorous?

I know - this is not Squeel.....I am using Squeel, and am trying to update my ransack gem - unfortunately ransack uses a newer version of the polyamorous gem and Squeel is stuck on the 1.1.0 version. Is there anyone here who can bump it up for us or allow it to use a newer version? If there is an incompatibility that would be good to inform folks about over on the Squeel repo. There are a number of us who are working on older code and it takes time to upgrade it - so switching to BabySqueel is not an option for me as of yet (I'm still on Rails/ActiveRecord 3.x)

This request was made a long time ago (and is still open) on the squeel repo here on activerecord-hackory/squeel. I'm hoping someone here has the ability to help out here!

ArgumentError in join_dependency.rb on edge

irb(main):012:0> 
t1 = Theme.find(1)
irb(main):013:0> t1.place
t1.place_ids         t1.place_theme_ids   t1.place_themes      t1.places            
t1.place_ids=        t1.place_theme_ids=  t1.place_themes=     t1.places=           
irb(main):013:0> t1.places
ArgumentError: wrong number of arguments (2 for 1)
    from /=skipped=/.bundle/gems/gems/polyamorous-1.2.0/lib/polyamorous/activerecord_4.2_ruby_2/join_dependency.rb:56:in `join_constraints'
    from /=skipped=/.bundle/gems/bundler/gems/rails-53d04697d5c9/activerecord/lib/active_record/relation/query_methods.rb:1010:in `build_join_query'
    from /=skipped=/.bundle/gems/bundler/gems/rails-53d04697d5c9/activerecord/lib/active_record/relation/query_methods.rb:991:in `build_joins'
    from /=skipped=/.bundle/gems/bundler/gems/rails-53d04697d5c9/activerecord/lib/active_record/relation/query_methods.rb:901:in `build_arel'
    from /=skipped=/.bundle/gems/bundler/gems/rails-53d04697d5c9/activerecord/lib/active_record/relation/query_methods.rb:888:in `arel'
    from /=skipped=/.bundle/gems/bundler/gems/rails-53d04697d5c9/activerecord/lib/active_record/relation/query_methods.rb:96:in `bound_attributes'
    from /=skipped=/.bundle/gems/bundler/gems/rails-53d04697d5c9/activerecord/lib/active_record/statement_cache.rb:94:in `create'
    from /=skipped=/.bundle/gems/bundler/gems/rails-53d04697d5c9/activerecord/lib/active_record/associations/collection_association.rb:447:in `block in get_records'
    from /=skipped=/.bundle/gems/bundler/gems/rails-53d04697d5c9/activerecord/lib/active_record/reflection.rb:361:in `block in association_scope_cache'
    from /=skipped=/.bundle/gems/bundler/gems/rails-53d04697d5c9/activerecord/lib/active_record/reflection.rb:360:in `synchronize'
    from /=skipped=/.bundle/gems/bundler/gems/rails-53d04697d5c9/activerecord/lib/active_record/reflection.rb:360:in `association_scope_cache'
    from /=skipped=/.bundle/gems/bundler/gems/rails-53d04697d5c9/activerecord/lib/active_record/reflection.rb:938:in `association_scope_cache'
    from /=skipped=/.bundle/gems/bundler/gems/rails-53d04697d5c9/activerecord/lib/active_record/associations/collection_association.rb:446:in `get_records'
    from /=skipped=/.bundle/gems/bundler/gems/rails-53d04697d5c9/activerecord/lib/active_record/associations/has_many_through_association.rb:194:in `find_target'
    from /=skipped=/.bundle/gems/bundler/gems/rails-53d04697d5c9/activerecord/lib/active_record/associations/collection_association.rb:401:in `load_target'
    from /=skipped=/.bundle/gems/bundler/gems/rails-53d04697d5c9/activerecord/lib/active_record/associations/collection_proxy.rb:45:in `load_target'
    from /=skipped=/.bundle/gems/bundler/gems/rails-53d04697d5c9/activerecord/lib/active_record/associations/collection_proxy.rb:968:in `to_ary'
    from /=skipped=/.bundle/gems/bundler/gems/rails-53d04697d5c9/activerecord/lib/active_record/relation.rb:676:in `inspect'
    from /=skipped=/.bundle/gems/bundler/gems/rails-53d04697d5c9/railties/lib/rails/commands/console.rb:65:in `start'
    from /=skipped=/.bundle/gems/bundler/gems/rails-53d04697d5c9/railties/lib/rails/commands/console_helper.rb:9:in `start'
    from /=skipped=/.bundle/gems/bundler/gems/rails-53d04697d5c9/railties/lib/rails/commands/commands_tasks.rb:69:in `console'
    from /=skipped=/.bundle/gems/bundler/gems/rails-53d04697d5c9/railties/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
    from /=skipped=/.bundle/gems/bundler/gems/rails-53d04697d5c9/railties/lib/rails/commands.rb:18:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'irb(main):014:0> 

and when ransack removed from Gemfile:

irb(main):008:0>t1 = Theme.find(1)
irb(main):009:0> t1.places
  Place Load (0.2ms)  SELECT "places".* FROM "places" INNER JOIN "place_themes" ON "places"."id" = "place_themes"."place_id" WHERE "place_themes"."theme_id" = ?  [["theme_id", 1]]
=> #<ActiveRecord::Associations::CollectionProxy []>

compatiblity broken in
rails/rails@3f46ef1
added ActiveRecord::Relation#left_outer_joins
Example:
User.left_outer_joins(:posts)
=> SELECT "users".* FROM "users" LEFT OUTER JOIN "posts" ON "posts"."user_id" = "users"."id"

Rails master (6.0) compactability

I'm trying to use features in Rails master branch (currently 6.0). Got

cannot load such file -- polyamorous/activerecord_6.0_ruby_2/join_association (LoadError)

With activerecord_5.2_ruby_2 got

activerecord/lib/active_record/associations/join_dependency/join_association.rb:12:in 'initialize': wrong number of arguments (given 3, expected 2)

Please help me to update this code.

Fails to load against Edge Rails

Heads up: it looks like something coming down the pike in Rails breaks Polyamorous. The whole thing's black magic to me so far, so I may be making a mistake, or this may be something that'll work itself out, but in case you haven't seen it:

When I bundle Rails from git master and Polyamorous 0.6.4, I get

...rails-f2ca5aa5c2e9/activesupport/lib/active_support/core_ext/module/aliasing.rb:32:in `alias_method': undefined method `graft' for class `ActiveRecord::Associations::JoinDependency' (NameError)

Joins on has_many associations raises ArgumentError for ActiveRecord 5.2.1

Joining two models that have a has_many association raises an ArgumentError.

If we have this two models:

class Article < ApplicationRecord
  belongs_to :author
end

class Author < ApplicationRecord
  has_many :articles
end

Running Article.joins(:author).to_sql raises a:

ArgumentError: wrong number of arguments (given 3, expected 2)

That's because ActiveRecord's Associations::JoinDependency::JoinAssociation class initializer changed in Rails 5.2.1 from:

def initialize(reflection, children, alias_tracker)
  ...
end
def initialize(reflection, children)
  ...
end

I don't know this codebase well enough but looking at the backtrace, seems to me that the class Polyamorous::JoinDependencyExtensions for ActiveRecord 5.2 needs an update.

This only happens in Rails 5.2.1, version 5.2.0 works fine :)

Can't "prepend" under JRuby 1.7

Concerns these lines:

https://github.com/activerecord-hackery/polyamorous/blob/master/lib/polyamorous.rb#L39-L42

If I run an app with jruby in mode 2.0, this condition will be evaluated, but jruby doesn't support the prepend option.

As much as this is not a problem of yours (JRuby apparently decided not to support it until the 9000 release), it still cripples my usage of the ransack gem.

Did you ever experience this yourself? Workaround suggestion? Or could the extra jruby condition added without problems? I see your travis.yml is not taking jruby into account, is this by design?

Rails 5.2 alpha

I'm trying out edge Rails 5.2 alpha in a project that uses ransack. So this line fails:

require "polyamorous/activerecord_#{ar_version}_ruby_#{ruby_version}/#{file}"

cannot load such file -- polyamorous/activerecord_5.2_ruby_2/join_association (LoadError)

What's your take on this? Should I just create those files? Copy paste the older ones? Should the conditional learn to simply load the latest version if none applicable can be found?

Thank you for your time!

Error with Rails 5.2.1

@jonatack @huoxito

When I upgrade to Rails 5.2.1, the application crashs with this error in gem:

wrong number of arguments (given 3, expected 2)

LINE WITH ERROR -->  polyamorous (1.3.3) lib/polyamorous/activerecord_5.2_ruby_2/join_dependency.rb:58:in `join_constraints'
activerecord (5.2.1) lib/active_record/relation/query_methods.rb:1027:in `build_join_query'
activerecord (5.2.1) lib/active_record/relation/query_methods.rb:1009:in `build_joins'
activerecord (5.2.1) lib/active_record/relation/query_methods.rb:929:in `build_arel'
activerecord (5.2.1) lib/active_record/relation/query_methods.rb:903:in `arel'
activerecord (5.2.1) lib/active_record/relation.rb:587:in `references_eager_loaded_tables?'
activerecord (5.2.1) lib/active_record/relation.rb:469:in `eager_loading?'
activerecord (5.2.1) lib/active_record/relation.rb:543:in `block in exec_queries'
activerecord (5.2.1) lib/active_record/relation.rb:578:in `skip_query_cache_if_necessary'
activerecord (5.2.1) lib/active_record/relation.rb:541:in `exec_queries'

It's an important issue, because we can't upgrade to Rails 5.2.1 for a while. This method in ActiveRecord changed the number of parameters.

wrong number of arguments Error when updating to Rails 5.2.1

I got this error. arity of JoinAssociation#initialize did changed between 5.2.0 and 5.2.1

ArgumentError - wrong number of arguments (given 3, expected 2):
  activerecord (5.2.1) lib/active_record/associations/join_dependency/join_association.rb:12:in `initialize'
  polyamorous (1.3.3) lib/polyamorous/activerecord_5.2_ruby_2/join_association.rb:19:in `initialize'
  polyamorous (1.3.3) lib/polyamorous/activerecord_5.2_ruby_2/join_dependency.rb:28:in `new'
  polyamorous (1.3.3) lib/polyamorous/activerecord_5.2_ruby_2/join_dependency.rb:28:in `block in build'
  polyamorous (1.3.3) lib/polyamorous/activerecord_5.2_ruby_2/join_dependency.rb:8:in `each'
  polyamorous (1.3.3) lib/polyamorous/activerecord_5.2_ruby_2/join_dependency.rb:8:in `map'
  polyamorous (1.3.3) lib/polyamorous/activerecord_5.2_ruby_2/join_dependency.rb:8:in `build'
  activerecord (5.2.1) lib/active_record/associations/join_dependency.rb:72:in `initialize'
  activerecord (5.2.1) lib/active_record/relation/finder_methods.rb:376:in `new'
  activerecord (5.2.1) lib/active_record/relation/finder_methods.rb:376:in `construct_join_dependency'
  activerecord (5.2.1) lib/active_record/relation/finder_methods.rb:382:in `apply_join_dependency'
  activerecord (5.2.1) lib/active_record/relation.rb:544:in `block in exec_queries'
  activerecord (5.2.1) lib/active_record/relation.rb:578:in `skip_query_cache_if_necessary'
  activerecord (5.2.1) lib/active_record/relation.rb:541:in `exec_queries'
  activerecord (5.2.1) lib/active_record/relation.rb:414:in `load'
  activerecord (5.2.1) lib/active_record/relation.rb:200:in `records'
  bullet (5.7.5) lib/bullet/active_record52.rb:50:in `records'
  activerecord (5.2.1) lib/active_record/relation/delegation.rb:41:in `each'
  app/views/articles/index.html.slim:14:in `_app_views_articles_index_html_slim___1619308452723666076_70194417953960'
  actionview (5.2.1) lib/action_view/template.rb:159:in `block in render'
  activesupport (5.2.1) lib/active_support/notifications.rb:170:in `instrument'
  actionview (5.2.1) lib/action_view/template.rb:354:in `instrument_render_template'
  actionview (5.2.1) lib/action_view/template.rb:157:in `render'
   () usr/local/Cellar/rbenv/1.1.1/versions/2.5.0/lib/ruby/gems/2.5.0/bundler/gems/rack-mini-profiler-ab2d911d2c17/lib/mini_profiler/profiling_methods.rb:104:in `block in profile_method'
  actionview (5.2.1) lib/action_view/renderer/template_renderer.rb:54:in `block (2 levels) in render_template'
  actionview (5.2.1) lib/action_view/renderer/abstract_renderer.rb:44:in `block in instrument'
  activesupport (5.2.1) lib/active_support/notifications.rb:168:in `block in instrument'
  activesupport (5.2.1) lib/active_support/notifications/instrumenter.rb:23:in `instrument'
  activesupport (5.2.1) lib/active_support/notifications.rb:168:in `instrument'
  actionview (5.2.1) lib/action_view/renderer/abstract_renderer.rb:43:in `instrument'
  actionview (5.2.1) lib/action_view/renderer/template_renderer.rb:53:in `block in render_template'
  actionview (5.2.1) lib/action_view/renderer/template_renderer.rb:61:in `render_with_layout'
  actionview (5.2.1) lib/action_view/renderer/template_renderer.rb:52:in `render_template'
  actionview (5.2.1) lib/action_view/renderer/template_renderer.rb:16:in `render'
  actionview (5.2.1) lib/action_view/renderer/renderer.rb:44:in `render_template'
  actionview (5.2.1) lib/action_view/renderer/renderer.rb:25:in `render'
  actionview (5.2.1) lib/action_view/rendering.rb:103:in `_render_template'
  actionpack (5.2.1) lib/action_controller/metal/streaming.rb:219:in `_render_template'
  actionview (5.2.1) lib/action_view/rendering.rb:84:in `render_to_body'
  actionpack (5.2.1) lib/action_controller/metal/rendering.rb:52:in `render_to_body'
  actionpack (5.2.1) lib/action_controller/metal/renderers.rb:142:in `render_to_body'
  actionpack (5.2.1) lib/abstract_controller/rendering.rb:25:in `render'
  actionpack (5.2.1) lib/action_controller/metal/rendering.rb:36:in `render'
  actionpack (5.2.1) lib/action_controller/metal/instrumentation.rb:46:in `block (2 levels) in render'
  activesupport (5.2.1) lib/active_support/core_ext/benchmark.rb:14:in `block in ms'
  /usr/local/Cellar/rbenv/1.1.1/versions/2.5.0/lib/ruby/2.5.0/benchmark.rb:308:in `realtime'
  activesupport (5.2.1) lib/active_support/core_ext/benchmark.rb:14:in `ms'
  actionpack (5.2.1) lib/action_controller/metal/instrumentation.rb:46:in `block in render'
  actionpack (5.2.1) lib/action_controller/metal/instrumentation.rb:87:in `cleanup_view_runtime'
  activerecord (5.2.1) lib/active_record/railties/controller_runtime.rb:31:in `cleanup_view_runtime'
  actionpack (5.2.1) lib/action_controller/metal/instrumentation.rb:45:in `render'
  meta-tags (2.10.0) lib/meta_tags/controller_helper.rb:20:in `render'
  remotipart (1.4.2) lib/remotipart/render_overrides.rb:16:in `render_with_remotipart'
  actionpack (5.2.1) lib/action_controller/metal/implicit_render.rb:35:in `default_render'
  actionpack (5.2.1) lib/action_controller/metal/basic_implicit_render.rb:6:in `block in send_action'
  actionpack (5.2.1) lib/action_controller/metal/basic_implicit_render.rb:6:in `tap'
  actionpack (5.2.1) lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
  actionpack (5.2.1) lib/abstract_controller/base.rb:194:in `process_action'
  actionpack (5.2.1) lib/action_controller/metal/rendering.rb:30:in `process_action'
  actionpack (5.2.1) lib/abstract_controller/callbacks.rb:42:in `block in process_action'
  activesupport (5.2.1) lib/active_support/callbacks.rb:132:in `run_callbacks'
  actionpack (5.2.1) lib/abstract_controller/callbacks.rb:41:in `process_action'
  actionpack (5.2.1) lib/action_controller/metal/rescue.rb:22:in `process_action'
  actionpack (5.2.1) lib/action_controller/metal/instrumentation.rb:34:in `block in process_action'
  activesupport (5.2.1) lib/active_support/notifications.rb:168:in `block in instrument'
  activesupport (5.2.1) lib/active_support/notifications/instrumenter.rb:23:in `instrument'
  activesupport (5.2.1) lib/active_support/notifications.rb:168:in `instrument'
  actionpack (5.2.1) lib/action_controller/metal/instrumentation.rb:32:in `process_action'
  actionpack (5.2.1) lib/action_controller/metal/params_wrapper.rb:256:in `process_action'
  activerecord (5.2.1) lib/active_record/railties/controller_runtime.rb:24:in `process_action'
  actionpack (5.2.1) lib/abstract_controller/base.rb:134:in `process'
  actionview (5.2.1) lib/action_view/rendering.rb:32:in `process'
   () usr/local/Cellar/rbenv/1.1.1/versions/2.5.0/lib/ruby/gems/2.5.0/bundler/gems/rack-mini-profiler-ab2d911d2c17/lib/mini_profiler/profiling_methods.rb:104:in `block in profile_method'
  actionpack (5.2.1) lib/action_controller/metal.rb:191:in `dispatch'
  actionpack (5.2.1) lib/action_controller/metal.rb:252:in `dispatch'
  actionpack (5.2.1) lib/action_dispatch/routing/route_set.rb:52:in `dispatch'
  actionpack (5.2.1) lib/action_dispatch/routing/route_set.rb:34:in `serve'
  actionpack (5.2.1) lib/action_dispatch/journey/router.rb:52:in `block in serve'
  actionpack (5.2.1) lib/action_dispatch/journey/router.rb:35:in `each'
  actionpack (5.2.1) lib/action_dispatch/journey/router.rb:35:in `serve'
  actionpack (5.2.1) lib/action_dispatch/routing/route_set.rb:840:in `call'
  rack-pjax (1.0.0) lib/rack/pjax.rb:12:in `call'
  rack (2.0.5) lib/rack/method_override.rb:22:in `call'
  rack (2.0.5) lib/rack/session/abstract/id.rb:232:in `context'
  rack (2.0.5) lib/rack/session/abstract/id.rb:226:in `call'
  actionpack (5.2.1) lib/action_dispatch/middleware/cookies.rb:670:in `call'
  serviceworker-rails (0.5.5) lib/serviceworker/middleware.rb:32:in `call'
  bullet (5.7.5) lib/bullet/rack.rb:14:in `call'
  remotipart (1.4.2) lib/remotipart/middleware.rb:32:in `call'
  warden (1.2.7) lib/warden/manager.rb:36:in `block in call'
  warden (1.2.7) lib/warden/manager.rb:35:in `catch'
  warden (1.2.7) lib/warden/manager.rb:35:in `call'
  rack (2.0.5) lib/rack/tempfile_reaper.rb:15:in `call'
  rack (2.0.5) lib/rack/etag.rb:25:in `call'
  rack (2.0.5) lib/rack/conditional_get.rb:25:in `call'
  rack-user_agent (0.5.2) lib/rack/user_agent.rb:16:in `call'
  rack (2.0.5) lib/rack/head.rb:12:in `call'
  actionpack (5.2.1) lib/action_dispatch/http/content_security_policy.rb:18:in `call'
  rack (2.0.5) lib/rack/session/abstract/id.rb:232:in `context'
  rack (2.0.5) lib/rack/session/abstract/id.rb:226:in `call'
  actionpack (5.2.1) lib/action_dispatch/middleware/cookies.rb:670:in `call'
  activerecord (5.2.1) lib/active_record/migration.rb:559:in `call'
  actionpack (5.2.1) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
  activesupport (5.2.1) lib/active_support/callbacks.rb:98:in `run_callbacks'
  actionpack (5.2.1) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
  actionpack (5.2.1) lib/action_dispatch/middleware/executor.rb:14:in `call'
  better_errors (2.4.0) lib/better_errors/middleware.rb:84:in `protected_app_call'
  better_errors (2.4.0) lib/better_errors/middleware.rb:79:in `better_errors_call'
  better_errors (2.4.0) lib/better_errors/middleware.rb:57:in `call'
  actionpack (5.2.1) lib/action_dispatch/middleware/debug_exceptions.rb:61:in `call'
  web-console (3.6.2) lib/web_console/middleware.rb:135:in `call_app'
  web-console (3.6.2) lib/web_console/middleware.rb:30:in `block in call'
  web-console (3.6.2) lib/web_console/middleware.rb:20:in `catch'
  web-console (3.6.2) lib/web_console/middleware.rb:20:in `call'
  actionpack (5.2.1) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
  railties (5.2.1) lib/rails/rack/logger.rb:38:in `call_app'
  railties (5.2.1) lib/rails/rack/logger.rb:26:in `block in call'
  activesupport (5.2.1) lib/active_support/tagged_logging.rb:71:in `block in tagged'
  activesupport (5.2.1) lib/active_support/tagged_logging.rb:28:in `tagged'
  activesupport (5.2.1) lib/active_support/tagged_logging.rb:71:in `tagged'
  railties (5.2.1) lib/rails/rack/logger.rb:26:in `call'
  sprockets-rails (3.2.1) lib/sprockets/rails/quiet_assets.rb:13:in `call'
  actionpack (5.2.1) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
  actionpack (5.2.1) lib/action_dispatch/middleware/request_id.rb:27:in `call'
  rack (2.0.5) lib/rack/method_override.rb:22:in `call'
  rack (2.0.5) lib/rack/runtime.rb:22:in `call'
  rack-rewrite (1.5.1) lib/rack/rewrite.rb:24:in `call'
  actionpack (5.2.1) lib/action_dispatch/middleware/executor.rb:14:in `call'
  actionpack (5.2.1) lib/action_dispatch/middleware/static.rb:127:in `call'
  rack (2.0.5) lib/rack/sendfile.rb:111:in `call'
   () usr/local/Cellar/rbenv/1.1.1/versions/2.5.0/lib/ruby/gems/2.5.0/bundler/gems/rack-mini-profiler-ab2d911d2c17/lib/mini_profiler/profiler.rb:285:in `call'
  webpacker (3.5.5) lib/webpacker/dev_server_proxy.rb:22:in `perform_request'
  rack-proxy (0.6.4) lib/rack/proxy.rb:57:in `call'
  railties (5.2.1) lib/rails/engine.rb:524:in `call'
  puma (3.12.0) lib/puma/configuration.rb:225:in `call'
  puma (3.12.0) lib/puma/server.rb:658:in `handle_request'
  puma (3.12.0) lib/puma/server.rb:472:in `process_client'
  puma (3.12.0) lib/puma/server.rb:332:in `block in run'
  puma (3.12.0) lib/puma/thread_pool.rb:133:in `block in spawn_thread'

Regression in polymorphic associations

This issue only affects Active Record 5.2.

In Active Record < 5.2, polymorphic joins will include a condition on the _type column.

LEFT OUTER JOIN "people"
ON "people"."id" = "notes"."notable_id" AND "notes"."notable_type" = 'Person'

In Active Record 5.2, the condition will not be included:

LEFT OUTER JOIN "people"
ON "people"."id" = "notes"."notable_id"

Relation to join dependency

I maintain a gem called baby_squeel here. It depends on polyamorous, and has some overlap with ransack.

The most irritating overlap is in building a join dependency from a relation, like ransack does here.

Any interest in co-maintaining a gem that converts a relation to a join dependency? I've created a repo here that baby_squeel will soon depend on.

I'd be happy to transfer this gem into the activerecord-hackery namespace. Alternatively, maybe this functionality could be merged into polyamorous?

Archive this repo

I think this repo should be marked archived, as the relevant code has been merged into Ransack and is not used anywhere else.

@gregmolnar WDYT?

Polyamorous not working with rails 5.2.1 due to join_dependency's interface changes

Hi, thanks for maintaining this awesome piece! ๐Ÿ˜ƒ

I came here, since it looks like polyamorous (specifically ActiveRecord join) is not working with Rails > 5.2.0 (confirmed it with 5-2-stable and 5.2.1)

Here's what I came up with after digging it a little further.

reproduction case

Let's say Item belongs to Category:

with rails 5.2.1,

pry(main)> Item.joins(:Category).first
ArgumentError: wrong number of arguments (given 3, expected 2)
from /Users/rails/my_rails_project/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.1/lib/active_record/associations/join_dependency/join_association.rb:12:in `initialize'

Not only initialize fails, but some other methods could fail depending on queries.

With rails 5.2.0 or earlier,

pry(main)> Item.joins(:Category).first
[DEBUG]   Item Load (5.4ms)  SELECT  `items`.* FROM `items` INNER JOIN `categories` ON `categories`.`id` = `items`.`category_id` LIMIT 1
=> #<Category:0x00007fd721a71a20
 id: 1
# ...snip

simply returns joined records (no surprise)

FYI, I'm using ransack (1.8.8) over polyamorous (1.3.3).

quick investigations..

(As seen in the error messages) there are mismatches in the number of arguments in some methods related with join_dependency between latest rails and polyamorous that overrides them.

Examples are: here (polyamorous) and here (latest ActiveRecord)

The background of this change is briefly explained here - apparently have been merged very recently.

As Rails 5.2.1 has just been released (and I personally need to update a rails app to the latest version), it would be really great if we get the fix for it.

In case PR is needed, I'm very happy to give it a try (wondering if somebody is already working on that..?)

Anyway, thanks a lot for maintaining this gem!

Breaks acts-as-taggable-on

polyamorous on rails-4.1 branch breaks acts-as-taggable-on with Postgres/PostGIS.
The error scenario is with Rails 4.1.0 and Ruby 1.9.3p448 , with acts-as-taggable-on 2.4.1 ,3.0.0 or 3.1.1

This causes errors like this one:

t = MyModel.first
> t.tag_list.add("something")
(0.9ms) SELECT f_geometry_column,coord_dimension,srid,type FROM geometry_columns WHERE f_table_name='taggings'
ArgumentError: wrong number of arguments (3 for 2)

For details see:
https://gist.github.com/tilo/85ce8bd382027d830ed1

The SQL statement that's generated looks utterly wrong.

when removing the polyamorous gem, it works again.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.