Created
November 24, 2012 13:09
-
-
Save mitoma/4139626 to your computer and use it in GitHub Desktop.
kaminari bug report. page メソッドを呼び出したとき、条件が欠落する場合がある。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# rails (3.2.8), kaminari (0.13.0) | |
# $> rails g model foo | |
# $> rails g model bar foo_id:integer | |
class Foo < ActiveRecord::Base | |
has_many :foo | |
end | |
class Bar < ActiveRecord::Base | |
belongs_to :foo | |
end | |
f = Foo.arel_table | |
b = Bar.arel_table | |
Foo.where(f[:id].in(b.project(:id).where(b[:id].eq(1)))).where(f[:id].in(b.project(:id).where(b[:id].eq(2)))) | |
#=> SELECT "foos".* FROM "foos" WHERE "foos"."id" IN (SELECT id FROM "bars" WHERE "bars"."id" = 1) AND "foos"."id" IN (SELECT id FROM "bars" WHERE "bars"."id" = 2) | |
Foo.where(f[:id].in(b.project(:id).where(b[:id].eq(1)))).where(f[:id].in(b.project(:id).where(b[:id].eq(2)))).page(nil) | |
#=> SELECT "foos".* FROM "foos" WHERE "foos"."id" IN (SELECT id FROM "bars" WHERE "bars"."id" = 2) LIMIT 25 OFFSET 0 | |
# 一つ目の in の副問い合わせが欠落している。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment