1. 25 9月, 2015 14 次提交
    • S
      Apply subsecond precision on assignment when using TZ aware attributes · 20b177b7
      Sean Griffin 提交于
      When a time object was assigned to a datetime column, the decorator for
      TZ aware attributes wouldn't call super, so when using a database
      without support for subsecond precision, the nanosecond would not be
      truncated, leading to the value being marked as changed.
      
      Interestingly, this also shows our new implementation of dirty checking
      to be more robust than the old one (with less code and better
      performance! 🎉!!!)
      20b177b7
    • S
      Remove debug statements · 370ef3e8
      Sean Griffin 提交于
      They didn't help.
      370ef3e8
    • A
      build the Set-Cookie header functionally · 9a1ca78d
      Aaron Patterson 提交于
      Use the Rack utility methods for functional header manipulation.  This
      helps to eliminate coupling on the header hash
      9a1ca78d
    • A
      move the Header hash to the super class · fcf5e178
      Aaron Patterson 提交于
      I want to move the header hash to the super request object in order to
      consolidate behavior.  We should be switching out buffering strategies
      rather than header strategies since things like "mutating headers after
      send" is an error in both cases (buffering vs streaming).
      fcf5e178
    • A
      mutate headers before committing the response · a2448e74
      Aaron Patterson 提交于
      We should not mutate headers after the response has been committed.
      a2448e74
    • S
      Add a few debug statements to figure out the build failure · bd6bea0f
      Sean Griffin 提交于
      Nobody can replicate locally and the failure makes no sense
      bd6bea0f
    • S
      We still need to reset `@changed_attributes` in `changes_applied` · 45735502
      Sean Griffin 提交于
      When I removed the call to `super` to avoid the setting of
      `@previous_changes`, I forgot to duplicate the other part of that
      behavior, which led to failing tests
      45735502
    • S
      Improve the performance of `save` and friends · 136fc65c
      Sean Griffin 提交于
      The biggest source of the performance regression in these methods
      occurred because dirty tracking required eagerly materializing and type
      casting the assigned values. In the previous commits, I've changed dirty
      tracking to perform the comparisons lazily. However, all of this is moot
      when calling `save`, since `changes_applied` will be called, which just
      ends up eagerly materializing everything, anyway. With the new mutation
      tracker, it's easy to just compare the previous two hashes in the same
      lazy fashion.
      
      We will not have aliasing issues with this setup, which is proven by the
      fact that we're able to detect nested mutation.
      
      Before:
          User.create! 2.007k (± 7.1%) i/s -     10.098k
      
      After:
          User.create! 2.557k (± 3.5%) i/s -     12.789k
      
      Fixes #19859
      136fc65c
    • S
      Encapsulate a lot of the logic from `Dirty` in an object · 8a811c83
      Sean Griffin 提交于
      In order to improve the performance of dirty checking, we're going to
      need to duplicate all of the `previous_` methods in Active Model.
      However, these methods are basically the same as their non-previous
      counterparts, but comparing `@original_attributes` to
      `@previous_original_attributes` instead of `@attributes` and
      `@original_attributes`. This will help reduce that duplication.
      8a811c83
    • S
      Clean up the implementation of AR::Dirty · 8e633e50
      Sean Griffin 提交于
      This moves a bit more of the logic required for dirty checking into the
      attribute objects. I had hoped to remove the `with_value_from_database`
      stuff, but unfortunately just calling `dup` on the attribute objects
      isn't enough, since the values might contain deeply nested data
      structures. I think this can be cleaned up further.
      
      This makes most dirty checking become lazy, and reduces the number of
      object allocations and amount of CPU time when assigning a value. This
      opens the door (but doesn't quite finish) to improving the performance
      of writes to a place comparable to 4.1
      8e633e50
    • R
      Merge pull request #21754 from lucasmazza/lm-assert-difference · adfb823a
      Rafael Mendonça França 提交于
      Make `assert_difference` return the result of the yielded block.
      adfb823a
    • L
      Make `assert_difference` return the result of the yielded block. · 564b1620
      Lucas Mazza 提交于
      With this we can perform new assertions on the returned value without having
      to cache it with an outer variable or wrapping all subsequent assertions inside
      the `assert_difference` block.
      
      Before:
      
      ```
      post = nil
      assert_difference -> { Post.count }, 1 do
        Post.create
      end
      
      assert_predicate post, :persisted?
      ```
      
      Now:
      
      ```
      post = assert_difference -> { Post.count } do
        Post.create
      end
      
      assert_predicate post, :persisted?
      ```
      564b1620
    • R
      Merge pull request #21753 from jonatack/fix-typo-in-ignored_columns_test · 9b966f62
      Rafael Mendonça França 提交于
      Fix typo in ignored_columns test [skip ci]
      9b966f62
    • J
      Fix typo in ignored_columns test [skip ci] · c5d42513
      Jon Atack 提交于
      Follow-up to #21720.
      c5d42513
  2. 24 9月, 2015 26 次提交