1. 26 1月, 2018 1 次提交
  2. 27 12月, 2017 1 次提交
  3. 12 12月, 2017 1 次提交
  4. 09 11月, 2017 4 次提交
  5. 18 8月, 2017 1 次提交
  6. 13 8月, 2017 1 次提交
    • R
      Fix `reflection.association_primary_key` for `has_many` associations · b23e8696
      Ryuta Kamizono 提交于
      It is incorrect to treat `options[:primary_key]` as
      `association_primary_key` if `has_many` associations because the
      `:primary_key` means the column on the owner record, not on the
      association record. It will break `ids_reader` and `ids_writer`.
      
      ```ruby
        people(:david).essay_ids
        # => ActiveRecord::StatementInvalid: Mysql2::Error: Unknown column 'essays.first_name' in 'field list': SELECT `essays`.first_name FROM `essays` WHERE `essays`.`writer_id` = 'David'
      ```
      
      Fixes #14439.
      b23e8696
  7. 20 7月, 2017 1 次提交
  8. 13 7月, 2017 1 次提交
  9. 02 7月, 2017 1 次提交
  10. 01 7月, 2017 1 次提交
  11. 30 6月, 2017 1 次提交
  12. 29 6月, 2017 1 次提交
  13. 28 6月, 2017 1 次提交
  14. 22 6月, 2017 1 次提交
  15. 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
  16. 01 6月, 2017 1 次提交
  17. 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
  18. 27 4月, 2017 3 次提交
  19. 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
  20. 22 4月, 2017 1 次提交
  21. 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
  22. 20 4月, 2017 1 次提交
  23. 26 3月, 2017 1 次提交
  24. 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
  25. 09 3月, 2017 1 次提交
  26. 01 3月, 2017 1 次提交
  27. 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
  28. 08 2月, 2017 1 次提交
    • K
      Use `count(:all)` in HasManyAssociation#count_records · 4a7b4f88
      Klas Eskilson 提交于
      Problem: Calling `count` on an association can cause invalid SQL queries
      to be created where the `SELECT COUNT(a, b, c)` function receives
      multiple  columns. This will cause a `StatementInvalid` exception later
      on.
      
      Solution: Use `count(:all)`, which generates a `SELECT COUNT(*)...`
      query independently of the association.
      
      This also includes a test case that, before the fix, broke.
      4a7b4f88
  29. 04 1月, 2017 1 次提交
  30. 30 12月, 2016 3 次提交
  31. 25 12月, 2016 2 次提交
  32. 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