3.2.4 Regression: unscoped broken if default_scope present #6577

toao opened this Issue May 31, 2012 · 7 comments


None yet

5 participants

toao commented May 31, 2012

I stumbled upon an issue after updating from 3.2.3 to 3.2.4 regarding resetting an default_scope with unscoped.

default_scope :conditions => { :deleted_at => nil }

SELECT COUNT(*) FROM "tours" WHERE "tours"."deleted_at" IS NULL

default-scope is applied as expected.

SELECT COUNT(*) FROM "tours" WHERE "tours"."deleted_at" IS NULL

default-scope is mistakenly used here, the WHERE-clause should be removed at this point! it seems that unscoped is ignored for any reason.


I think this is a duplicate of #6576 as well - what's happening is the relation is cached but not reset between the queries which is why the default_scope is being applied.

radar commented Jun 1, 2012

I have duplicated this issue successfully on a 3.2.4 application and reverted commit @ac465d5 and it then works.


thanks @radar we did the same. But I think that @pixeltrix is trying to find a better solution.

@pixeltrix pixeltrix added a commit that referenced this issue Jun 1, 2012
@pixeltrix pixeltrix Restore behavior of Active Record 3.2.3 scopes
A series of commits relating to preloading and scopes caused a regression.
Cloning the relation calls initialize_copy which resets a number of instance
variables to nil. Without this the scope thinks that it is already loaded
when it is called again.

Reverts the following commits:

Fixes #6575, #6576 & #6577
toao commented Jun 1, 2012

thanks guys, especially @pixeltrix, awesome work!


Did anyone else get a email saying that this was still broken on 3.2.5 ?

fabiob commented Jun 5, 2012

I did posted a commend saying it was still broken, and then deleted. Looks like the notification still went out.

It was my mistake, I haven't restarted my app to load the new Rails environment once I upgraded. Sorry for the trouble.


@fabiob no worries, just thought I was going crazy :)

@jahnique jahnique pushed a commit to zweitag/spree that referenced this issue Dec 13, 2013
@radar radar Revert back to Rails 3.2.3
This is due to a number of regressions reported in Rails:


As well as a failing test inside of api brought on by rails/rails@ac465d5.

There is also the issue of link_to_function's deprecation in this version of Rails, which is still used in a couple of places in Spree.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment