1. 26 6月, 2014 4 次提交
    • S
      Consolidate testing of update_all type casting · 58d38d6d
      Sean Griffin 提交于
      We have several test cases on "tricky" types that are essentially
      testing that `update_all` goes through the same type casting behavior as
      a normal assignment + save. We recently had another case to add this
      test for another type in https://github.com/rails/rails/pull/12742.
      
      Rather than testing this separately for every type which is "tricky"
      when round tripping, let's instead have a fairly exhaustive test that
      ensures we're getting the correct values at every step for `update_all`.
      Given the structure of the code now, we can be confident that if the
      type is correct, and `update_all` is type casting correctly, we're going
      to get the right behavior for all types.
      58d38d6d
    • 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
    • S
      `Attribute` should know about its name · bb7bc499
      Sean Griffin 提交于
      This allows using polymorphism for the uninitialized attributes raising
      an exception behavior.
      bb7bc499
    • S
      Encapsulate the creation of `Attribute` objects · 14b1208d
      Sean Griffin 提交于
      This will make it less painful to add additional properties, which
      should persist across writes, such as `name`.
      
      Conflicts:
      	activerecord/lib/active_record/attribute_set.rb
      14b1208d
  2. 25 6月, 2014 2 次提交
    • S
      Move behavior of `read_attribute` to `AttributeSet` · a89f8a92
      Sean Griffin 提交于
      Moved `Builder` to its own file, as it started looking very weird once I
      added private methods to the `AttributeSet` class and the `Builder`
      class started to grow.
      
      Would like to refactor `fetch_value` to change to
      
      ```ruby
      self[name].value(&block)
      ```
      
      But that requires the attributes to know about their name, which they
      currently do not.
      a89f8a92
    • Y
      `preload` preserves readonly flag on associations. #15853 · 5706d290
      Yves Senn 提交于
      This is a partial fix for #15853. It only works when a `preload`
      is issued and not an `eager_load`. I've added a skipped failing
      test-case to keep in mind that we need to deal with `eager_load`.
      5706d290
  3. 24 6月, 2014 1 次提交
    • S
      Always assume strings with non-numeric characters change numeric types · 50fa3667
      Sean Griffin 提交于
      We previously only did this if the old value was zero, to make sure
      numericality validations run and failed if the user gave 'wibble' as the
      value, which would be type cast to 0. However, numericality validations
      will fail if there are any non-numeric characters in the string, so 5 ->
      '5wibble' should also be marked as changed.
      50fa3667
  4. 23 6月, 2014 3 次提交
  5. 22 6月, 2014 4 次提交
  6. 21 6月, 2014 1 次提交
  7. 20 6月, 2014 3 次提交
  8. 18 6月, 2014 12 次提交
  9. 17 6月, 2014 4 次提交
  10. 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
  11. 14 6月, 2014 5 次提交