rzane / baby_squeel

:pig: An expressive query DSL for Active Record
MIT License
500 stars 49 forks source link

Breaks all Rails 5 has_many through relationship #106

Closed SaimonL closed 3 years ago

SaimonL commented 5 years ago

Issue

In any Rails 5 application if you create has many through relation then this gem causes it to break.

Reproduction

Just create a new Rails 5 or 6 app and add the following model with migrations.

class User < ApplicationRecord
  has_many :memberships
  has_many :groups, through: :memberships
end

class Group < ApplicationRecord
  has_many :memberships
  has_many :users, through: :memberships
end

class Membership < ApplicationRecord
  belongs_to :user
  belongs_to :group
end

Now when you try to do User.first.groups it will cash. Remove this gem and it all works fine.

Error I get:

Group.first.users
  Group Load (0.5ms)  SELECT  "groups".* FROM "groups" ORDER BY "groups"."id" ASC LIMIT $1  [["LIMIT", 1]]
Traceback (most recent call last):
ArgumentError (wrong number of arguments (given 3, expected 2))
rocket-turtle commented 3 years ago

I think this issue is fixed in 1.4.0.beta1 - April 21, 2021 (20 KB) and should be closed.

rzane commented 3 years ago

I'm going to assume this is fixed, but if this is still an issue, please follow up.