1. 16 1月, 2015 1 次提交
  2. 31 12月, 2014 1 次提交
  3. 09 12月, 2014 1 次提交
  4. 29 11月, 2014 1 次提交
  5. 28 11月, 2014 1 次提交
  6. 26 11月, 2014 1 次提交
    • S
      Setting an association replaces records with the same id in memory · dd986814
      Sean Griffin 提交于
      The records weren't being replaced since equality in Active Record is
      defined in terms of `id` only. It is reasonable to expect that the
      references would be replaced in memory, even if no queries are actually
      executed. This change did not appear to affect any other parts of the
      code base. I chose not to execute callbacks since we're not actually
      modifying the association in a way that will be persisted.
      
      Fixes #17730
      dd986814
  7. 14 11月, 2014 1 次提交
  8. 08 11月, 2014 1 次提交
  9. 23 10月, 2014 1 次提交
  10. 03 10月, 2014 1 次提交
    • B
      Fix that a collection proxy could be cached before the save of the owner,... · cc405496
      Ben Woosley 提交于
      Fix that a collection proxy could be cached before the save of the owner, resulting in an invalid proxy lacking the owner’s id.
      
      Absent this fix calls like: owner.association.update_all to behave unexpectedly because they try to act on association objects where
      owner_id is null.
      
      more evidence here: https://gist.github.com/Empact/5865555
      ```
      Active Record 3.2.13
      -- create_table(:firms, {:force=>true})
         -> 0.1371s
      -- create_table(:clients, {:force=>true})
         -> 0.0005s
      1 clients. 1 expected.
      1 clients updated. 1 expected.
      ```
      
      ```
      Active Record 4.0.0
      -- create_table(:firms, {:force=>true})
         -> 0.1606s
      -- create_table(:clients, {:force=>true})
         -> 0.0004s
      1 clients. 1 expected.
      0 clients updated. 1 expected.
      ```
      cc405496
  11. 06 9月, 2014 1 次提交
  12. 28 8月, 2014 1 次提交
  13. 26 6月, 2014 1 次提交
    • S
      Deprecate automatic counter caches on has_many :through · d730e374
      Sean Griffin 提交于
      Reliant on https://github.com/rails/rails/pull/15747 but pulled to a
      separate PR to reduce noise. `has_many :through` associations have the
      undocumented behavior of automatically detecting counter caches.
      However, the way in which it does so is inconsistent with counter caches
      everywhere else, and doesn't actually work consistently.
      
      As with normal `has_many` associations, the user should specify the
      counter cache on the `belongs_to`, if they'd like it updated.
      d730e374
  14. 16 6月, 2014 1 次提交
    • S
      Always update counter caches in memory when adding records · e6690d37
      Sean Griffin 提交于
      Before, calling `size` would only work if it skipped the cache, and
      would return a different result from the cache, but only if:
      
      - The association was previously loaded
      - Or you called size previously
      - But only if the size was 0 when you called it
      
      This ensures that the counter is appropriately updated in memory.
      e6690d37
  15. 10 6月, 2014 1 次提交
  16. 10 5月, 2014 1 次提交
  17. 04 5月, 2014 2 次提交
  18. 03 5月, 2014 1 次提交
  19. 01 5月, 2014 1 次提交
  20. 29 4月, 2014 1 次提交
    • E
      add test to check that loaded and non laoded are the same · 748daa39
      eileencodes 提交于
      Test checks that SQL is the same for a loaded vs not loaded
      association (category.categorizations, category.categorization.delete_all
      vs category.cartegroization.delete_al). This was fixed for delete_all
      dependency but was not fixed for no (:nullify, or nil) dependency).
      748daa39
  21. 04 4月, 2014 1 次提交
  22. 03 4月, 2014 1 次提交
  23. 01 4月, 2014 1 次提交
  24. 01 3月, 2014 1 次提交
  25. 21 2月, 2014 1 次提交
  26. 09 2月, 2014 1 次提交
  27. 31 1月, 2014 1 次提交
  28. 28 1月, 2014 1 次提交
  29. 22 1月, 2014 1 次提交
    • J
      Ensure AR #second, #third, etc. finders work through associations · 03855e79
      Jason Meller 提交于
      This commit fixes two regressions introduced in cafe31a0 where
      newly created finder methods #second, #third, #forth, and #fifth
      caused a NoMethodError error on reload associations and where we
      were pulling the wrong element out of cached associations.
      
      Examples:
      
        some_book.authors.reload.second
      
        # Before
        # => NoMethodError: undefined method 'first' for nil:NilClass
      
        # After
        # => #<Author id: 2, name: "Sally Second", ...>
      
        some_book.first.authors.first
        some_book.first.authors.second
      
        # Before
        # => #<Author id: 1, name: "Freddy First", ...>
        # => #<Author id: 1, name: "Freddy First", ...>
      
        # After
        # => #<Author id: 1, name: "Freddy First", ...>
        # => #<Author id: 2, name: "Sally Second", ...>
      
      Fixes #13783.
      03855e79
  30. 19 12月, 2013 1 次提交
  31. 26 11月, 2013 3 次提交
    • H
      changed update counter to act on unscoped model · 45d4d141
      heruku 提交于
      45d4d141
    • B
      Raise `RecordNotDestroyed` when children can't be replaced · 5aab0c05
      Brian Thomas Storti 提交于
      Fixes #12812
      Raise `ActiveRecord::RecordNotDestroyed` when a child marked with
      `dependent: destroy` can't be destroyed.
      
      The following code:
      ```ruby
      class Post < ActiveRecord::Base
        has_many :comments, dependent: :destroy
      end
      
      class Comment < ActiveRecord::Base
        before_destroy do
          return false
        end
      end
      
      post = Post.create!(comments: [Comment.create!])
      post.comments = [Comment.create!]
      ````
      
      would result in a `post` with two `comments`.
      With this commit, the same code would raise a `RecordNotDestroyed`
      exception, keeping the `post` with the same `comment`.
      5aab0c05
    • V
      Fix some minor typos [ci skip] · 82de1eda
      Vipul A M 提交于
      82de1eda
  32. 21 11月, 2013 1 次提交
    • J
      Fix ActiveRecord::Relation#unscope · 64b9e93b
      Jon Leighton 提交于
      I'm pretty confused about the addition of this method. The documentation
      says that it was intended to allow the removal of values from the
      default scope (in contrast to #except). However it behaves exactly the
      same as except: https://gist.github.com/jonleighton/7537008 (other than
      having a slightly enhanced syntax).
      
      The removal of the default scope is allowed by
      94924dc3, which was not a change we
      could make until 4.1 due to the need to deprecate things. However after
      that change #unscope still gives us nothing that #except doesn't already
      give us.
      
      However there *is* a desire to be able to unscope stuff in a way that
      persists across merges, which would allow associations to be defined
      which unscope stuff from the default scope of the associated model. E.g.
      
        has_many :comments, -> { unscope where: :trashed }
      
      So that's what this change implements. I've also corrected the
      documentation. I removed the guide references to #except as I think
      unscope really supercedes #except now.
      
      While we're here, there's also a potential desire to be able to write
      this:
      
        has_many :comments, -> { unscoped }
      
      However, it doesn't make sense and would not be straightforward to
      implement. While with #unscope we're specifying exactly what we want to
      be removed from the relation, with "unscoped" we're just saying that we
      want it to not have some things which were added earlier on by the
      default scope. However in the case of an association, we surely don't
      want *all* conditions to be removed, otherwise the above would just
      become "SELECT * FROM comments" with no foreign key constraint.
      
      To make the above work, we'd have to somehow tag the relation values
      which get added when evaluating the default scope in order to
      differentiate them from other relation values. Which is way too much
      complexity and therefore not worth it when most use cases can be
      satisfied with unscope.
      
      Closes #10643, #11061.
      64b9e93b
  33. 17 11月, 2013 1 次提交
  34. 02 11月, 2013 2 次提交
  35. 29 10月, 2013 1 次提交
  36. 28 9月, 2013 1 次提交
    • P
      Removed where_values_hash from AR::NullRelation · 8fb0de2c
      Paul Nikitochkin 提交于
      In order to build associated records for owners which has not been saved
      need to get where values to use as default attributes.
      But for new record owner uses `ActiveRecord::NullRelation` which
      override `where_values_hash` to return empty hash stub.
      
      `where_values_hash` is not used to invoke any sql query, but good to
      build others chains (even will be never executed) like:
      
      ```ruby
        post          = Post.new
        admin_comment = post.admin_comments.build
      
        assert_equal 'Admin', admin_comment.author
      ```
      
      Closes #11376, #11676, #11675
      8fb0de2c