1. 02 6月, 2014 1 次提交
    • S
      Remove most code related to serialized properties · 90c8be76
      Sean Griffin 提交于
      Nearly completely implemented in terms of custom properties.
      `_before_type_cast` now stores the raw serialized string consistently,
      which removes the need to keep track of "state". The following is now
      consistently true:
      
      - `model.serialized == model.reload.serialized`
      - A model can be dumped and loaded infinitely without changing
      - A model can be saved and reloaded infinitely without changing
      90c8be76
  2. 31 5月, 2014 1 次提交
    • S
      Rename attribute related instance variables to better express intent · eb6cee9c
      Sean Griffin 提交于
      `@attributes` was actually used for `_before_type_cast` and friends,
      while `@attributes_cache` is the type cast version (and caching is the
      wrong word there, but I'm working on removing the conditionals around
      that). I opted for `@raw_attributes`, because `_before_type_cast` is
      also semantically misleading. The values in said hash are in the state
      given by the form builder or database, so raw seemed to be a good word.
      eb6cee9c
  3. 20 5月, 2014 1 次提交
    • S
      Remove :timestamp column type · d0f8c46e
      Sean Griffin 提交于
      The `:timestamp` type for columns is unused. All database adapters treat
      them as the same database type. All code in `ActiveRecord` which changes
      its behavior based on the column's type acts the same in both cases.
      However, when the type is passed to code that checks for the `:datetime`
      type, but not `:timestamp` (such as XML serialization), the result is
      unexpected behavior.
      
      Existing schema definitions will continue to work, and the `timestamp`
      type is transparently aliased to `datetime`.
      d0f8c46e
  4. 19 12月, 2013 1 次提交
  5. 11 9月, 2013 1 次提交
  6. 04 7月, 2013 4 次提交
  7. 03 7月, 2013 4 次提交
  8. 18 2月, 2013 1 次提交
  9. 22 11月, 2012 1 次提交
    • J
      Don't allocate new strings in compiled attribute methods · ae934aef
      Jon Leighton 提交于
      This improves memory and performance without having to use symbols which
      present DoS problems. Thanks @headius and @tenderlove for the
      suggestion.
      
      This was originally committed in
      f1765019, and then reverted in
      d3494903 due to it causing problems in a
      real application. This second attempt should solve that.
      
      Benchmark
      ---------
      
      require 'active_record'
      require 'benchmark/ips'
      
      ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
      
      class Post < ActiveRecord::Base
        connection.create_table :posts, force: true do |t|
          t.string :name
        end
      end
      
      post = Post.create name: 'omg'
      
      Benchmark.ips do |r|
        r.report('Post.new')          { Post.new name: 'omg' }
        r.report('post.name')         { post.name }
        r.report('post.name=')        { post.name = 'omg' }
        r.report('Post.find(1).name') { Post.find(1).name }
      end
      
      Before
      ------
      
      Calculating -------------------------------------
                  Post.new      1419 i/100ms
                 post.name      7538 i/100ms
                post.name=      3024 i/100ms
         Post.find(1).name       243 i/100ms
      -------------------------------------------------
                  Post.new    20637.6 (±12.7%) i/s -     102168 in   5.039578s
                 post.name  1167897.7 (±18.2%) i/s -    5186144 in   4.983077s
                post.name=    64305.6 (±9.6%) i/s -     317520 in   4.998720s
         Post.find(1).name     2678.8 (±10.8%) i/s -      13365 in   5.051265s
      
      After
      -----
      
      Calculating -------------------------------------
                  Post.new      1431 i/100ms
                 post.name      7790 i/100ms
                post.name=      3181 i/100ms
         Post.find(1).name       245 i/100ms
      -------------------------------------------------
                  Post.new    21308.8 (±12.2%) i/s -     105894 in   5.053879s
                 post.name  1534103.8 (±2.1%) i/s -    7634200 in   4.979405s
                post.name=    67441.0 (±7.5%) i/s -     337186 in   5.037871s
         Post.find(1).name     2681.9 (±10.6%) i/s -      13475 in   5.084511s
      ae934aef
  10. 01 11月, 2012 1 次提交
  11. 26 10月, 2012 1 次提交
    • J
      Remove ActiveRecord::Model · 9e4c41c9
      Jon Leighton 提交于
      In the end I think the pain of implementing this seamlessly was not
      worth the gain provided.
      
      The intention was that it would allow plain ruby objects that might not
      live in your main application to be subclassed and have persistence
      mixed in. But I've decided that the benefit of doing that is not worth
      the amount of complexity that the implementation introduced.
      9e4c41c9
  12. 21 10月, 2012 1 次提交
  13. 20 10月, 2012 1 次提交
    • J
      Get rid of the ActiveRecord::Model::DeprecationProxy thing. · 83846838
      Jon Leighton 提交于
      I think it's going to be too much pain to try to transition the
      :active_record load hook from executing against Base to executing
      against Model.
      
      For example, after Model is included in Base, and modules included in
      Model will no longer get added to the ancestors of Base.
      
      So plugins which wish to be compatible with both Model and Base should
      use the :active_record_model load hook which executes *before* Base gets
      loaded.
      
      In general, ActiveRecord::Model is an advanced feature at the moment and
      probably most people will continue to inherit from ActiveRecord::Base
      for the time being.
      83846838
  14. 12 10月, 2012 2 次提交
    • J
      Don't allocate new strings in compiled attribute methods · f1765019
      Jon Leighton 提交于
      This improves memory and performance without having to use symbols which
      present DoS problems. Thanks @headius and @tenderlove for the
      suggestion.
      
      Benchmark
      ---------
      
      require 'active_record'
      require 'benchmark/ips'
      
      ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database:
      ':memory:')
      
      class Post < ActiveRecord::Base
        connection.create_table :posts, force: true do |t|
          t.string :name
        end
      end
      
      post = Post.create name: 'omg'
      
      Benchmark.ips do |r|
        r.report('Post.new')          { Post.new name: 'omg' }
        r.report('post.name')         { post.name }
        r.report('post.name=')        { post.name = 'omg' }
        r.report('Post.find(1).name') { Post.find(1).name }
      end
      
      Before
      ------
      
      Calculating -------------------------------------
                  Post.new      1419 i/100ms
                 post.name      7538 i/100ms
                post.name=      3024 i/100ms
         Post.find(1).name       243 i/100ms
      -------------------------------------------------
                  Post.new    20637.6 (±12.7%) i/s -     102168 in   5.039578s
                 post.name  1167897.7 (±18.2%) i/s -    5186144 in   4.983077s
                post.name=    64305.6 (±9.6%) i/s -     317520 in   4.998720s
         Post.find(1).name     2678.8 (±10.8%) i/s -      13365 in   5.051265s
      
      After
      -----
      
      Calculating -------------------------------------
                  Post.new      1431 i/100ms
                 post.name      7790 i/100ms
                post.name=      3181 i/100ms
         Post.find(1).name       245 i/100ms
      -------------------------------------------------
                  Post.new    21308.8 (±12.2%) i/s -     105894 in   5.053879s
                 post.name  1534103.8 (±2.1%) i/s -    7634200 in   4.979405s
                post.name=    67441.0 (±7.5%) i/s -     337186 in   5.037871s
         Post.find(1).name     2681.9 (±10.6%) i/s -      13475 in   5.084511s
      f1765019
    • J
      Revert "Key the attributes hash with symbols" · 9e5f7cc6
      Jon Leighton 提交于
      This reverts commit 86c3dfbd.
      
      Conflicts:
      	activerecord/lib/active_record/attribute_methods/read.rb
      
      Reason: whilst this increased performance, it also presents a DoS risk
      via memory exhaustion if users were allowing user input to dictate the
      arguments of read/write_attribute. I will investigate alternative ways
      to cut down on string allocations here.
      9e5f7cc6
  15. 22 9月, 2012 1 次提交
  16. 01 9月, 2012 1 次提交
  17. 31 8月, 2012 1 次提交
    • J
      Key the attributes hash with symbols · 86c3dfbd
      Jon Leighton 提交于
      This is a performance/GC optimisation.
      
      In theory, this could be optimised by the implementation (last time I
      checked, this would have no effect on JRuby). But in practise, this make
      attribute access faster.
      86c3dfbd
  18. 25 8月, 2012 1 次提交
  19. 16 6月, 2012 1 次提交
  20. 30 3月, 2012 2 次提交
  21. 28 3月, 2012 2 次提交
  22. 10 2月, 2012 2 次提交
  23. 09 2月, 2012 4 次提交
  24. 08 2月, 2012 4 次提交