aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/attribute_methods/read.rb
Commit message (Collapse)AuthorAgeFilesLines
...
* Perf: avoid dupes add fallback logic for codersSam2013-09-111-7/+8
|
* method transplanting between modules isn't supported on 1.9Aaron Patterson2013-07-031-3/+26
|
* refactor the method cache objects to have a superclassAaron Patterson2013-07-031-26/+8
|
* move the reader method cache in to the read moduleAaron Patterson2013-07-031-1/+49
|
* keep a cache of the reader methods so we can reuse themAaron Patterson2013-07-031-34/+2
|
* reduce the amount of code Ruby has to parseAaron Patterson2013-07-021-3/+8
|
* making the comment more accurateAaron Patterson2013-07-021-2/+5
|
* stop storing multiple copies of a particular attribute nameAaron Patterson2013-07-021-2/+3
|
* eagerly assign the attribute name cache, remove const_missingAaron Patterson2013-07-021-0/+2
|
* Gist URLs are now namespacedAkira Matsuda2013-02-181-1/+1
| | | | see: https://github.com/blog/1406-namespaced-gists
* Don't allocate new strings in compiled attribute methodsJon Leighton2012-11-211-12/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 f1765019ce9b6292f2264b4601dad5daaffe3a89, and then reverted in d3494903719682abc0948bef290af0d3d7b5a440 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
* Revert "Don't allocate new strings in compiled attribute methods"David Heinemeier Hansson2012-10-311-27/+12
| | | | This reverts commit f1765019ce9b6292f2264b4601dad5daaffe3a89.
* Remove ActiveRecord::ModelJon Leighton2012-10-261-7/+2
| | | | | | | | | | 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.
* Revert "Get rid of the ActiveRecord::Model::DeprecationProxy thing."Jeremy Kemper2012-10-201-1/+1
| | | | This reverts commit 83846838252397b3781eed165ca301e05db39293.
* Get rid of the ActiveRecord::Model::DeprecationProxy thing.Jon Leighton2012-10-191-1/+1
| | | | | | | | | | | | | | | | | 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.
* Don't allocate new strings in compiled attribute methodsJon Leighton2012-10-121-12/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Revert "Key the attributes hash with symbols"Jon Leighton2012-10-121-9/+5
| | | | | | | | | | | | This reverts commit 86c3dfbd47cb96af02daaa655963292b1a1b110e. 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.
* update AR/attribute_methods documentation [ci skip]Francesco Rodriguez2012-09-211-5/+7
|
* Avoid #fetch for non-nil values.Jon Leighton2012-08-311-1/+2
| | | | | | This is purely a performance optimisation. See https://gist.github.com/3552829
* Key the attributes hash with symbolsJon Leighton2012-08-311-4/+9
| | | | | | | | 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.
* call methods on AR::Model after ClassMethods module is definedAaron Patterson2012-08-241-1/+2
|
* Simplify AR configuration code.Jon Leighton2012-06-151-2/+6
| | | | | Get rid of ActiveModel::Configuration, make better use of ActiveSupport::Concern + class_attribute, etc.
* recurse in read_attribute we get caching / don't duplicate codeJon Leighton2012-03-301-3/+2
|
* Properly typecast id attribute when using custom primary keyCarlos Antonio da Silva2012-03-291-1/+4
|
* much code can be deleted thanks to @tenderlove's refactoringJon Leighton2012-03-281-58/+6
|
* attributes are cached by string keys, so to_s to support symbols. fixes #5549Aaron Patterson2012-03-271-1/+1
|
* removing dead codeAaron Patterson2012-02-091-4/+0
|
* only exclude serialized columns from cacheable columnsAaron Patterson2012-02-091-1/+5
|
* removed unnecessary translator objectAaron Patterson2012-02-081-16/+0
|
* use the key name yielded to the fetch blockAaron Patterson2012-02-081-9/+7
|
* return early if the cast attribute has been cachedAaron Patterson2012-02-081-11/+16
|
* always call `read_attribute` from the reader methodAaron Patterson2012-02-081-14/+12
|
* cache attribute if it is supposed to be cachedAaron Patterson2012-02-071-1/+5
|
* moving column types to an ivar on the resultAaron Patterson2012-02-071-1/+5
|
* moved attribute translation to an objectAaron Patterson2012-02-071-16/+10
|
* moved most of the evald code in to regular ruby codeAaron Patterson2012-02-071-10/+28
|
* copy the columns hash to the active record instances, typecast using columns ↵Aaron Patterson2012-02-071-3/+10
| | | | looked up on the instance
* The primary key is always initialized in the @attributes hash to nil (unlessAaron Patterson2012-01-251-5/+1
| | | | another value has been specified).
* use fetch rather than both Hash#key? and Hash#[]Aaron Patterson2012-01-251-49/+51
|
* Revert "just use an alias. The target method is public, so make this one ↵Aaron Patterson2012-01-201-1/+4
| | | | | | public" This reverts commit be7d2248e9505983d1aacf0b33c657e6e3ddd9db.
* just use an alias. The target method is public, so make this one publicAaron Patterson2012-01-191-4/+1
| | | | too.
* Support configuration on ActiveRecord::Model.Jon Leighton2011-12-281-1/+4
| | | | | | | | | | | | | | | The problem: We need to be able to specify configuration in a way that can be inherited to models that include ActiveRecord::Model. So it is no longer sufficient to put 'top level' config on ActiveRecord::Base, but we do want configuration specified on ActiveRecord::Base and descendants to continue to work. So we need something like class_attribute that can be defined on a module but that is inherited when ActiveRecord::Model is included. The solution: added ActiveModel::Configuration module which provides a config_attribute macro. It's a bit specific hence I am not putting this in Active Support or making it a 'public API' at present.
* Deal with global config better between AR::Base and AR::ModelJon Leighton2011-12-241-4/+1
|
* Doh, remove debugging lineJon Leighton2011-12-231-1/+0
|
* Fix #4046.Jon Leighton2011-12-231-4/+3
|
* Make read_attribute code path accessible at the class levelJon Leighton2011-12-221-19/+21
|
* Stop the build asploding on 1.8.7Jon Leighton2011-12-141-0/+2
|
* Use a separate module for 'external' attribute methods.Jon Leighton2011-12-141-14/+9
|
* fixing eval'd line numbers.Aaron Patterson2011-12-081-2/+2
|
* Revert "Roflscaling!" (for now)Jon Leighton2011-12-021-6/+9
| | | | | | | | This reverts commit f6b5046305d43c5f64bcb6fed0e44f7bca99a603. Fear not, the roflscale will return when I have a bit more time and figure out a better way to do it. (In particular, a way that doesn't break the build.)