1. 13 7月, 2017 1 次提交
  2. 02 7月, 2017 1 次提交
  3. 01 7月, 2017 1 次提交
  4. 30 6月, 2017 1 次提交
  5. 29 6月, 2017 1 次提交
  6. 28 6月, 2017 1 次提交
  7. 22 6月, 2017 1 次提交
  8. 21 6月, 2017 1 次提交
    • J
      Clear offset cache on CollectionProxy reset/reload · c7f669af
      John Hawthorn 提交于
      The `@offsets` cache is used by FinderMethods to cache records found by
      find_nth. This cache is cleared in AR::Relation#reset, but not in
      CollectionProxy#reset or CollectionProxy#reload.
      
      Because of this, since #29098, calling #first/#find_nth/etc after
      calling #reload or #reset on an association could return a stale record.
      This is an issue both when the full association target is loaded and
      when the item is loaded in #find_nth.
      
      This commit solves the problem by clearing the `@offsets` cache in
      CollectionProxy#reset and CollectionProxy#reload.
      c7f669af
  9. 01 6月, 2017 1 次提交
  10. 28 5月, 2017 1 次提交
    • R
      Fix association with extension issues · 9b78974b
      Ryuta Kamizono 提交于
      This fixes the following issues.
      
      * `association_scope` doesn't include `default_scope`. Should use `scope` instead.
      * We can't use `method_missing` for customizing existing method.
      * We can't use `relation_delegate_class` for sharing extensions. Should extend per association.
      9b78974b
  11. 27 4月, 2017 2 次提交
  12. 26 4月, 2017 1 次提交
    • R
      Remove useless test case · 111ae374
      Ryuta Kamizono 提交于
      Cannot call private methods in `@klass` against `CollectionProxy`
      (inherites `Relation`) because using `public_send` in `method_missing`.
      111ae374
  13. 22 4月, 2017 1 次提交
  14. 21 4月, 2017 1 次提交
    • R
      Prevent double firing the before save callback of new object when the parent... · c0038f7c
      Ryuta Kamizono 提交于
      Prevent double firing the before save callback of new object when the parent association saved in the callback
      
      Related #18155, #26661, 268a5bb0, #27434, #27442, and #28599.
      
      Originally #18155 was introduced for preventing double insertion caused
      by the after save callback. But it was caused the before save issue
      (#26661). 268a5bb0 fixed #26661, but it was caused the performance
      regression (#27434). #27442 added new record to `target` before calling
      callbacks for fixing #27434. But it was caused double firing before save
      callback (#28599). We cannot add new object to `target` before saving
      the object.
      
      This is improving #18155 to only track callbacks after `save`.
      
      Fixes #28599.
      c0038f7c
  15. 20 4月, 2017 1 次提交
  16. 26 3月, 2017 1 次提交
  17. 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
  18. 09 3月, 2017 1 次提交
  19. 01 3月, 2017 1 次提交
  20. 28 2月, 2017 1 次提交
    • E
      Dupping a CollectionProxy should dup the load_target · ca8c21df
      eileencodes 提交于
      In Rails 3.2 dupping a `CollectionProxy` would dup it's `load_target` as
      well. That functionality has been broken since the release of Rails 4.0.
      I hit this in an application upgrade and wondered why duplicating a
      CollectionProxy and assigning it to a variable stopped working.
      
      When calling `dup` on a `CollectionProxy` only the owner (ex.
      topic) was getting duplicated and the `load_target` would remain in tact
      with it's original object ID. Dupping the `load_target` is useful for performing
      a logging operation after records have been destroyed in a method.
      
      For example:
      
      ```
      def transfer_operation
        saved_replies = topic.replies
      
        topic.replies.clear
      
        saved_replies.each do |reply|
          user.update_replies_count!
        end
      end
      ```
      
      This change adds a `initialize_dup` method that performs a `deep_dup` on
      the `@associatiation` so that the `load_target` is dupped as well.
      
      Fixes #17117
      ca8c21df
  21. 04 1月, 2017 1 次提交
  22. 30 12月, 2016 3 次提交
  23. 25 12月, 2016 2 次提交
  24. 23 12月, 2016 1 次提交
    • R
      Add a record to target before any callbacks loads the record · 9eee7822
      Ryuta Kamizono 提交于
      `append_record` was added at 15ddd517 for not double adding the record.
      But adding `append_record` (checking `@target.include?(record)`) caused
      performance regression #27434. Instead of checking not double adding the
      record, add a record to target before any callbacks loads the record.
      
      Fixes #27434.
      9eee7822
  25. 03 12月, 2016 1 次提交
  26. 13 11月, 2016 1 次提交
    • R
      Respect new records for `CollectionProxy#uniq` · 0ec967aa
      Ryuta Kamizono 提交于
      Currently if `CollectionProxy` has more than one new record,
      `CollectionProxy#uniq` result is incorrect.
      
      And `CollectionProxy#uniq` was aliased to `distinct` in a1bb6c8b.
      But the `uniq` method and the `SELECT DISTINCT` method are different
      methods. The doc in `CollectionProxy` is for the `SELECT DISTINCT`
      method, not for the `uniq` method.
      
      Therefore, reverting the alias in `CollectionProxy` to fix the
      inconsistency and to have the both methods.
      0ec967aa
  27. 03 11月, 2016 1 次提交
  28. 29 10月, 2016 1 次提交
  29. 22 10月, 2016 1 次提交
  30. 30 9月, 2016 1 次提交
    • S
      Don't skip in-memory insertion of associations when loaded in validate · 268a5bb0
      Sean Griffin 提交于
      This was caused by 6d0d83a3. While the
      bug it's trying to fix is handled if the association is loaded in an
      after_(create|save) callback, it doesn't handle any cases that load the
      association before the persistence takes place (validation, or before_*
      filters). Instead of caring about the timing of persistence, we can just
      ensure that we're not double adding the record instead.
      
      The test from that commit actually broke, but it was not because the bug
      has been re-introduced. It was because `Bulb` in our test suite is doing
      funky things that look like STI but isn't STI, so equality comparison
      didn't happen as the loaded model was of a different class.
      
      Fixes #26661.
      268a5bb0
  31. 17 9月, 2016 1 次提交
  32. 16 8月, 2016 3 次提交
  33. 14 8月, 2016 2 次提交