1. 14 2月, 2019 1 次提交
  2. 05 2月, 2019 1 次提交
    • R
      Chaining named scope is no longer leaking to class level querying methods · 2935d075
      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.
      2935d075
  3. 18 1月, 2019 1 次提交
  4. 26 9月, 2018 1 次提交
  5. 26 4月, 2018 1 次提交
  6. 19 4月, 2018 1 次提交
  7. 30 3月, 2018 1 次提交
  8. 26 1月, 2018 3 次提交
  9. 28 11月, 2017 1 次提交
  10. 09 11月, 2017 2 次提交
  11. 13 8月, 2017 1 次提交
  12. 20 7月, 2017 1 次提交
  13. 02 7月, 2017 1 次提交
  14. 01 7月, 2017 1 次提交
  15. 01 6月, 2017 1 次提交
  16. 19 3月, 2017 1 次提交
    • R
      Use `load` rather than `collect` for force loading · 59db5f22
      Ryuta Kamizono 提交于
      Since b644964b `ActiveRecord::Relation` includes `Enumerable` so
      delegating `collect`, `all?`, and `include?` are also unneeded.
      `collect` without block returns `Enumerable` without preloading by that.
      We should use `load` rather than `collect` for force loading.
      59db5f22
  17. 25 2月, 2017 1 次提交
  18. 29 10月, 2016 1 次提交
  19. 17 9月, 2016 1 次提交
  20. 16 8月, 2016 1 次提交
  21. 07 8月, 2016 3 次提交
  22. 19 7月, 2016 1 次提交
    • S
      Fix the calling `merge` method at first in a scope · cf2574b1
      suginoy 提交于
      Changing the order of method chaining `merge` and other query
      method such as `joins` should produce the same result.
      
      ```ruby
      class Topic < ApplicationRecord
        scope :safe_chaininig,   -> { joins(:comments).merge(Comment.newest) }
        scope :unsafe_chaininig, -> { merge(Comment.newest).joins(:comments) } #=> NoMethodError
      end
      ```
      cf2574b1
  23. 05 5月, 2016 1 次提交
  24. 03 5月, 2016 1 次提交
    • S
      Do not delegate `AR::Base#empty?` to `all` · 98264a13
      Sean Griffin 提交于
      Unlike `one?` and `none?`, `empty?` has interactions with methods
      outside of enumerable. It also doesn't fit in the same vein.
      `Topic.any?` makes sense. `Topic.empty?` does not, as `Topic` is not a
      container.
      
      Fixes #24808
      Close #24812
      98264a13
  25. 29 3月, 2016 1 次提交
  26. 28 1月, 2016 3 次提交
  27. 26 8月, 2015 1 次提交
  28. 21 2月, 2015 1 次提交
    • F
      Error message testing fix · b1d26350
      Franky W 提交于
      The testing of error messages have been implemented wrongly a few times.
      This is an attempt to fix it.
      
      For example, some of these test should have failed with the new code.
      The reason they are not failling with the new string is the fact they
      were not being tested beforehand.
      b1d26350
  29. 28 1月, 2015 1 次提交
    • S
      `WhereClause#predicates` does not need to be public · d26dd008
      Sean Griffin 提交于
      The only place it was accessed was in tests. Many of them have another
      way that they can test their behavior, that doesn't involve reaching
      into internals as far as they did. `AssociationScopeTest` is testing a
      situation where the where clause would have one bind param per
      predicate, so it can just ignore the predicates entirely. The where
      chain test was primarly duplicating the logic tested on `WhereClause`
      directly, so I instead just make sure it calls the appropriate method
      which is fully tested in isolation.
      d26dd008
  30. 26 1月, 2015 1 次提交
  31. 14 11月, 2014 1 次提交
  32. 24 10月, 2014 1 次提交
  33. 04 9月, 2014 1 次提交
    • G
      Enums shouldn't ruin people's anniversaries · 94b7328b
      Godfrey Chan 提交于
      Added a few more methods on Module/Class to the dangerous class methods
      blacklist. (Technically, allocate and new are already protected currently because
      we happen to redefine them in the current implantation.)
      
      Closes #16792
      94b7328b