Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EagerLoadPolymorphicError being thrown whenever conditions used #129

Open
ghost opened this issue May 16, 2011 · 3 comments
Open

EagerLoadPolymorphicError being thrown whenever conditions used #129

ghost opened this issue May 16, 2011 · 3 comments

Comments

@ghost
Copy link

ghost commented May 16, 2011

I am running will_paginate 3.0.pre2 on rails 3.0.7, and there seems to be some type of strange bug where a EagerLoadPolymorphicError is being raised whenever almost any conditions are used.

My 2 relevant models are very simple:
class Book
boolean public
belongs_to :author, :polymorphic => true
end
class Individual
has_many :books, :as => :author
end
class Group
has_many :books, :as => :author
end

This query will raise the exception:
Book.where(:public => true).includes(:author).paginate(:page => @page, :per_page => page_size, :order => "id DESC")

I have tried modifying the condition in a number of ways, and the only way that makes it not throw an exception is if the condition is on the id column, oddly enough.

@mislav
Copy link
Owner

mislav commented Aug 9, 2011

Looks like an Active Record bug. Can you try again with latest will_paginate from master branch and Rails 3.0.9? Thanks

@ghost
Copy link
Author

ghost commented Aug 9, 2011

I just tried on Rails 3.0.9 with will_paginate 3.0.0 and the bug still behaves the same.

Book.where(:public => true).includes(:author).limit(10).order(:id) works correctly.
Book.where(:public => true).includes(:author).paginate(:page => 1, :per_page => 10, :order => :id) fails
Book.where(:id => [1,2,3]).includes(:author).paginate(:page => 1, :per_page => 10, :order => :id) works correctly.

@mislav
Copy link
Owner

mislav commented Aug 9, 2011

Thanks for all the info. I will try to work around the bug. The current test suite doesn't have polymorphic associations, so this went undetected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant