- 15 11月, 2019 1 次提交
-
-
由 Ryuta Kamizono 提交于
Follow up of #35280. If a model has default scopes, vanilla `klass.all` is not the same with `klass.unscoped`. In that case, we should use `klass.default_scoped` instead.
-
- 02 10月, 2019 1 次提交
-
-
由 Takayuki Nakata 提交于
`except` was removed at b77dd218
-
- 13 6月, 2019 1 次提交
-
-
由 Ryuta Kamizono 提交于
We sometimes say "
✂ ️ newline after `private`" in a code review (e.g. https://github.com/rails/rails/pull/18546#discussion_r23188776, https://github.com/rails/rails/pull/34832#discussion_r244847195). Now `Layout/EmptyLinesAroundAccessModifier` cop have new enforced style `EnforcedStyle: only_before` (https://github.com/rubocop-hq/rubocop/pull/7059). That cop and enforced style will reduce the our code review cost.
-
- 06 4月, 2019 1 次提交
-
-
由 Ryuta Kamizono 提交于
Follow up of #35868. Closes #19349.
-
- 15 2月, 2019 1 次提交
-
-
由 Ryuta Kamizono 提交于
This deprecates using class level querying methods if the receiver scope regarded as leaked, since #32380 and #35186 may cause that silently leaking information when people upgrade the app. We need deprecation first before making those.
-
- 07 2月, 2019 1 次提交
-
-
由 Ryuta Kamizono 提交于
Don't use `false` as special value to skip to find inherited scope, we could use `skip_inherited_scope = true`, and move `_scoping` back on Relation.
-
- 05 2月, 2019 1 次提交
-
-
由 Ryuta Kamizono 提交于
Active Record uses `scoping` to delegate to named scopes from relations for propagating the chaining source scope. It was needed to restore the source scope in named scopes, but it was caused undesired behavior that pollute all class level querying methods. Example: ```ruby class Topic < ActiveRecord::Base scope :toplevel, -> { where(parent_id: nil) } scope :children, -> { where.not(parent_id: nil) } scope :has_children, -> { where(id: Topic.children.select(:parent_id)) } end # Works as expected. Topic.toplevel.where(id: Topic.children.select(:parent_id)) # Doesn't work due to leaking `toplevel` to `Topic.children`. Topic.toplevel.has_children ``` Since #29301, the receiver in named scopes has changed from the model class to the chaining source scope, so the polluting class level querying methods is no longer required for that purpose. Fixes #14003.
-
- 21 12月, 2018 1 次提交
-
-
- 09 10月, 2018 1 次提交
-
-
由 Ryuta Kamizono 提交于
The delegation methods to named scope are defined when `method_missing` is invoked on the relation. Since #29301, the receiver in the named scope is changed to the relation like others (e.g. `default_scope`, etc) for consistency. Most named scopes would be delegated from relation by `method_missing`, since we don't allow scopes to be defined which conflict with instance methods on `Relation` (#31179). But if a named scope is defined with the same name as any method on the `superclass` (e.g. `Kernel.open`), the `method_missing` on the relation is not invoked. To address the issue, make the delegation methods to named scope is generated in the definition time. Fixes #34098.
-
- 11 9月, 2018 2 次提交
-
-
由 Ryuta Kamizono 提交于
-
由 Ryuta Kamizono 提交于
`scoping` stashes the reciever and then returning that as `klass.all`. `all.scoping` has no effect to the public behavior, so it is redundant.
-
- 27 3月, 2018 1 次提交
-
-
由 Ryuta Kamizono 提交于
The receiver in a scope was changed from `klass` to `relation` itself for all scopes (named scope, default_scope, and association scope) behaves consistently. In addition. Before 5.2, if both an AR model class and a Relation instance have same named methods (e.g. `arel_attribute`, `predicate_builder`, etc), named scope doesn't respect relation instance information. For example: ```ruby class Post < ActiveRecord::Base has_many :comments1, class_name: "RecentComment1" has_many :comments2, class_name: "RecentComment2" end class RecentComment1 < ActiveRecord::Base self.table_name = "comments" default_scope { where(arel_attribute(:created_at).gteq(2.weeks.ago)) } end class RecentComment2 < ActiveRecord::Base self.table_name = "comments" default_scope { recent_updated } scope :recent_updated, -> { where(arel_attribute(:updated_at).gteq(2.weeks.ago)) } end ``` If eager loading `Post.eager_load(:comments1, :comments2).to_a`, `:comments1` (default_scope) respects aliased table name, but `:comments2` (using named scope) may not work correctly since named scope doesn't respect relation instance information. See also 801ccab2. But this is a breaking change between releases without deprecation. I decided to bring back private class methods accessibility in named scope. Fixes #31740. Fixes #32331.
-
- 28 11月, 2017 1 次提交
-
-
由 Chen Kinnrot 提交于
Due to inconsistent behavior when chaining scopes and one scope named after a Relation method Validation code added in 2 places: - scope, to prevent problematic scope names. - enum, cause it tries to auto define scope.
-
- 06 11月, 2017 1 次提交
-
-
由 Ryuta Kamizono 提交于
A relation includes `klass`, so it can not be used as it is if current class is different from `current_scope.klass`. It should be created new relation by current class to respect the klass and STI constraint. Fixes #17603. Fixes #23576.
-
- 15 8月, 2017 1 次提交
-
-
由 Ryuta Kamizono 提交于
Follow up of #29834. Fixes #30266.
-
- 20 7月, 2017 1 次提交
-
-
由 Kir Shatrov 提交于
-
- 02 7月, 2017 1 次提交
-
-
由 Matthew Draper 提交于
This reverts commit 3420a145, reversing changes made to afb66a5a.
-
- 01 7月, 2017 1 次提交
-
-
由 Kir Shatrov 提交于
-
- 27 6月, 2017 1 次提交
-
-
由 Ryuta Kamizono 提交于
-
- 01 6月, 2017 1 次提交
-
-
由 Ryuta Kamizono 提交于
Currently the receiver in a scope is `klass`, not `relation`. I think it is a strange because the receiver in `default_scope` and a scope on association is `relation`. I fixed to the receiver is to be a `relation` properly for consistency.
-
- 30 5月, 2017 1 次提交
-
-
由 Ryuta Kamizono 提交于
As @matthewd's suggestion, if `klass` has no default scope, it will more faster.
-
- 28 5月, 2017 1 次提交
-
-
由 Ryuta Kamizono 提交于
-
- 24 5月, 2017 1 次提交
-
-
由 Ryuta Kamizono 提交于
-
- 29 12月, 2016 1 次提交
-
-
由 Rafael Mendonça França 提交于
Some methods were added to public API in 5b14129d and they should be not part of the public API.
-
- 24 12月, 2016 1 次提交
-
-
由 Akira Matsuda 提交于
-
- 27 10月, 2016 1 次提交
-
-
由 bogdanvlviv 提交于
Mainly around `nil` [ci skip]
-
- 07 8月, 2016 1 次提交
-
-
由 Xavier Noria 提交于
The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
-
- 03 8月, 2016 1 次提交
-
-
由 monmon 提交于
-
- 28 1月, 2016 1 次提交
-
-
由 Akira Matsuda 提交于
This reverts commit f6db31ec. Reason: Scope names can very easily conflict, particularly when sharing Concerns within the team, or using multiple gems that extend AR models. It is true that Ruby has the ability to detect this with the -w option, but the reality is that we are depending on too many gems that do not care about Ruby warnings, therefore it might not be a realistic solution to turn this switch on in our real-world apps.
-
- 14 10月, 2015 1 次提交
-
-
由 Yves Senn 提交于
The focus of this change is to make the API more accessible. References to method and classes should be linked to make it easy to navigate around. This patch makes exzessiv use of `rdoc-ref:` to provide more readable docs. This makes it possible to document `ActiveRecord::Base#save` even though the method is within a separate module `ActiveRecord::Persistence`. The goal here is to bring the API closer to the actual code that you would write. This commit only deals with Active Record. The other gems will be updated accordingly but in different commits. The pass through Active Record is not completely finished yet. A follow up commit will change the spots I haven't yet had the time to update. /cc @fxn
-
- 08 10月, 2015 1 次提交
-
-
由 Tommaso Visconti 提交于
Adds a paragraph to the documentation of the `ActiveRecord::Scoping::Named.scope` method, explaining that the method is intended to return an ActiveRecord::Relation object to be composable with other scopes. In the case that in the case that `nil` or `false` are returned, the method returns an `all` relation instead. This unexpected behaviour is mentioned in #19249 #14256 #21465 and #21882 and wasn't documented at all. This commit adds this documentation.
-
- 12 3月, 2015 1 次提交
-
-
由 Ben Woosley 提交于
Instead use .scope_attributes? consistently in ActiveRecord to check whether there are attributes currently associated with the scope. Move the implementation of .scope_attributes? and .scope_attributes to ActiveRecord::Scoping because they don't particularly have to do specifically with Named scopes and their only dependency, in the case of .scope_attributes?, and only caller, in the case of .scope_attributes is contained in Scoping.
-
- 12 2月, 2015 1 次提交
-
-
由 Sean Griffin 提交于
It looks like the only reason `current_scope` was thread local on `base_class` instead of `self` is to ensure that when we call a named scope created with a proc on the parent class, it correctly uses the default scope of the subclass. The reason this wasn't happening was because the proc captured `self` as the parent class, and we're not actually defining a real method. Using `instance_exec` fixes the problem. Fixes #18806
-
- 07 2月, 2015 1 次提交
-
-
由 Rafael Mendonça França 提交于
Relation#merge checks if the argument is an array and the only possible returns of build_default_scope is nil or a Relation. Doing this we can raise an ArgumentError when Relation#merge receive a nil value.
-
- 12 11月, 2014 1 次提交
-
-
由 Andrey Deryabin 提交于
-
- 24 10月, 2014 1 次提交
-
-
由 Mauro George 提交于
This changes the actual exception `NoMethodError: undefined method `call' for #<ActiveRecord::Relation []>` to a `ArgumentError` when try to define a scope without a callable.
-
- 21 5月, 2014 1 次提交
-
-
由 Rafael Mendonça França 提交于
This reverts commit 9a1abedc, reversing changes made to c72d6c91. 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.
-
- 24 4月, 2014 1 次提交
-
-
由 Jefferson Lai 提交于
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.
-
- 30 1月, 2014 1 次提交
-
-
由 Godfrey Chan 提交于
Similar to dangerous attribute methods, a scope name conflict is dangerous if it conflicts with an existing class method defined within `ActiveRecord::Base` but not its ancestors. See also #13389. *Godfrey Chan*, *Philippe Creux*
-
- 06 8月, 2013 1 次提交
-
-
由 Rafael Mendonça França 提交于
The deprecation message was removed on 50cbc03d but the code was not.
-