1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
Commit graph

13 commits

Author SHA1 Message Date
Rafael Mendonça França
6931bed1b4 Revert "Merge pull request #14544 from jefflai2/named_scope_sti"
This reverts commit 9a1abedcde, reversing
changes made to c72d6c91a7.

Conflicts:
	activerecord/CHANGELOG.md
	activerecord/test/models/comment.rb

This change break integration with activerecord-deprecated_finders so
I'm reverting until we find a way to make it work with this gem.
2014-05-21 12:15:57 -03:00
Jefferson Lai
9c3afdc327 Fixes Issue #13466.
Changed the call to a scope block to be evaluated with instance_eval.
The result is that ScopeRegistry can use the actual class instead of base_class when
caching scopes so queries made by classes with a common ancestor won't leak scopes.
2014-04-23 17:21:45 -07:00
Keenan Brock
8cbd500035 Move changed_attributes into dirty.rb
Move serialization dirty into serialization.rb
2014-01-22 13:47:34 -05:00
Xavier Noria
e5ef3abdd2 hides the per thread registry instance, and caches singleton methods
Existing code was delegating to the instance with delegate
macro calls, or invoking the instance method to reach
the object and call its instance methods.

But the point is to have a clean class-level interface where
the thread local instance is hidden in the implementation.

References #11c6973.
References #10198.
2013-04-13 17:09:13 +02:00
wangjohn
e12901e423 Changed the ScopeRegistry and the InstrumentationRegistry to use the
PerThreadRegistry module.
2013-04-09 22:27:32 -04:00
wangjohn
a332712503 Delegating the value getter and setters in the ScopeRegistry to the
current ScopeRegister object.
2013-04-08 15:18:14 -04:00
wangjohn
5b945f2685 Grouping thread locals in the ActiveRecord scopes so that the
current_scope and ignore_default_scope locals are brought together under
a registry object.
2013-04-08 13:21:13 -04:00
Jon Leighton
8606a7fbe9 Fix scope chaining + STI
See #9869 and #9929.

The problem arises from the following example:

    class Project < ActiveRecord::Base
      scope :completed, -> { where completed: true }
    end

    class MajorProject < Project
    end

When calling:

    MajorProject.where(tasks_count: 10).completed

This expands to:

    MajorProject.where(tasks_count: 10).scoping {
      MajorProject.completed
    }

However the lambda for the `completed` scope is defined on Project. This
means that when it is called, `self` is Project rather than
MajorProject. So it expands to:

    MajorProject.where(tasks_count: 10).scoping {
      Project.where(completed: true)
    }

Since the scoping was applied on MajorProject, and not Project, this
fails to apply the tasks_count condition.

The solution is to make scoping apply across STI classes. I am slightly
concerned about the possible side-effects of this, but no tests fail and
it seems ok. I guess we'll see.
2013-04-05 13:14:28 +01:00
Carlos Antonio da Silva
2cb576ef36 Refactor to use each_key, remove extra spaces 2013-01-28 23:25:03 -02:00
Xavier Noria
64bc8447c2 load active_support/concern in active_support/rails 2012-08-02 21:59:23 +02:00
Jon Leighton
d242e46781 extract #with_scope and #with_exclusive_scope to active_record_deprecated_finders 2012-04-25 15:45:06 +01:00
Jon Leighton
2b22564c4e Move DefaultScope and NamedScope under Scoping 2011-12-15 20:45:42 +00:00
Jon Leighton
ceb33f8493 Split out most of the AR::Base code into separate modules 🍰 2011-12-15 20:45:37 +00:00