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

Paranoia inhibits chaining of multiple #having statements on an AR::Relation #116

Closed
moxie opened this issue Feb 21, 2014 · 1 comment
Closed

Comments

@moxie
Copy link

moxie commented Feb 21, 2014

class Person < ActiveRecord::Base
  acts_as_paranoid
end
>  Person.group(:name).having("count(id) > 1").having("count(id) < 1").to_sql
=> "SELECT `people`.* FROM `people`  WHERE `people`.`deleted_at` IS NULL GROUP BY name HAVING count(id) > 1"

upon removing acts_as_paranoid from the model:

>  Person.group(:name).having("count(id) > 1").having("count(id) < 1").to_sql
=> "SELECT `people`.* FROM `people`  GROUP BY name HAVING count(id) > 1 AND count(id) < 1"

I realize the #having statements used here are nonsensical, but hopefully this demonstrates the point. Please let me know if there is anything else I can do to help with this issue. I haven't been able to identify anything in the paranoia implementation that would cause this... but I don't really know how deep scopes, unscoped, etc goes.

Edit: I also should have specified this is with paranoia 2.0.2 and Rails 4.0.0. I did also test against Rails 4.0.3 because initially I thought it might have been an ActiveRecord issue, but the same behavior occurred there.

@moxie
Copy link
Author

moxie commented Feb 21, 2014

Apparently this is a known Rails issue where default_scopes are invloved. rails/rails#13965

@moxie moxie closed this as completed Feb 21, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant