aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/attribute_methods
Commit message (Collapse)AuthorAgeFilesLines
...
* Rename the partial_updates config to partial_writesJon Leighton2012-10-191-6/+18
| | | | This reflects the fact that it now impact inserts as well as updates.
* The default value of a text/blob in mysql strict mode should be nilJon Leighton2012-10-191-11/+1
| | | | | | | | | In non-strict mode it is '', but if someone is in strict mode then we should honour the strict semantics. Also, this removes the need for a completely horrible hack in dirty.rb. Closes #7780
* Don't allocate new strings in compiled attribute methodsJon Leighton2012-10-122-20/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-123-12/+8
| | | | | | | | | | | | 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.
* Merge branch 'master' of github.com:lifo/docrailsVijay Dev2012-09-285-30/+40
|\ | | | | | | | | Conflicts: actionpack/lib/action_view/helpers/asset_tag_helper.rb
| * update AR/attribute_methods documentation [ci skip]Francesco Rodriguez2012-09-214-26/+36
| |
| * fix AR::AttributeMethods::Dirty :nodoc: [ci skip]Francesco Rodriguez2012-09-211-4/+4
| |
* | Support for partial inserts.Jon Leighton2012-09-281-3/+17
| | | | | | | | | | | | | | | | | | | | | | When inserting new records, only the fields which have been changed from the defaults will actually be included in the INSERT statement. The other fields will be populated by the database. This is more efficient, and also means that it will be safe to remove database columns without getting subsequent errors in running app processes (so long as the code in those processes doesn't contain any references to the removed column).
* | Removing dead code. attribute_cast_code is not called.kennyj2012-09-282-25/+0
|/
* Set primary key with id= only if primary key existsGuillermo Iguaran2012-09-161-1/+1
|
* Remove mass assignment security from ActiveRecordGuillermo Iguaran2012-09-161-2/+1
|
* Raise MissingAttributeError on query methodsErnie Miller2012-09-081-1/+1
| | | | | | | | | | | | | When calling a query method on an attribute that was not selected by an ActiveRecord query, an ActiveModel::MissingAttributeError is not raised. Instead, a nil value is returned, which will return false once cast to boolean. This is undesirable, as we should not give the impression that we know the attribute's boolean value when we haven't loaded the attribute's (possibly) non-boolean value from the database. This issue is present on versions going back as far as 2.3, at least.
* Minor refactor in ActiveRecord#initialize_dupCarlos Antonio da Silva2012-09-071-1/+0
| | | | | | * There is no need to delete the primary key from cloned attributes, since it sets the same pk to nil afterwards. * Check for empty? instead of any? to run initialize callbacks.
* 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-313-7/+12
| | | | | | | | 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
|
* Use instance_accessor: false instead of instance_writer.kennyj2012-08-211-2/+7
|
* Round usec when writing timestamp attribute.kennyj2012-08-211-5/+14
|
* Pull more serialize code into a lazy included moduleJon Leighton2012-08-171-60/+63
|
* Optimize instantiation for models which don't use serializeJon Leighton2012-08-171-13/+20
| | | | Those z's were hard to type.
* load active_support/core_ext/class/attribute in active_support/railsXavier Noria2012-08-022-2/+0
|
* load active_support/core_ext/object/inclusion in active_support/railsXavier Noria2012-08-021-1/+0
|
* load active_support/core_ext/object/blank in active_support/railsXavier Noria2012-08-022-2/+0
|
* Do not consider the numeric attribute as changed if the old value isRafael Mendonça França2012-08-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | zero and the new value is not a string. Before this commit this was the behavior r = Review.find_by_issue(0) r.issue => 0 r.changes => {} r.issue = 0 => 0 r.changed? => true r.changes => {"issue"=>[0,0]} Fixes #7237 Conflicts: activerecord/CHANGELOG.md
* Added *instance_writer: false* for stored/serialized attributes.kennyj2012-07-071-1/+1
|
* changed the firm of changes_from_zero_to_string?Angelo capilleri2012-06-211-2/+2
| | | | delete *column* because is unused by the method.
* Refactor the conditionalsRafael Mendonça França2012-06-191-7/+7
|
* Validates_numericality_of is skipped when changing 0 to to non-empty stringAngelo capilleri2012-06-191-5/+15
| | | | | | | | | | This happens when A has_many many B and A accepts_nested_attributes B that has a numeric colum with initial 0 value. So a.update_attributes({:b_attributes => { :id => b.id, :numeric => 'foo' }}) passes the validation test but, the value of :numeric doesn't change. his commit forces that the update fails with the above conditions. Fixes #6393 Fixes #2331
* Simplify AR configuration code.Jon Leighton2012-06-154-9/+23
| | | | | Get rid of ActiveModel::Configuration, make better use of ActiveSupport::Concern + class_attribute, etc.
* Fix #6591. If a field with timezone isn't changed, we don't call will_change!.kennyj2012-06-041-1/+2
|
* Fix #5797. Error calling dup method on AR model with serialized fieldkennyj2012-05-301-3/+4
|
* 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-282-64/+6
|
* attributes are cached by string keys, so to_s to support symbols. fixes #5549Aaron Patterson2012-03-271-1/+1
|
* Remove IdentityMapCarlos Antonio da Silva2012-03-131-5/+0
|
* Remove unusused variablesJon Leighton2012-03-041-3/+2
|
* Merge pull request #5196 from lest/patch-3José Valim2012-02-281-0/+1
|\ | | | | force datetime attributes to be changed, fix GH #3965
| * force datetime attributes to be changed, fix GH #3965Sergey Nartimov2012-02-281-0/+1
| |
* | remove unnecessary codeSergey Nartimov2012-02-281-6/+0
|/ | | | | it was added in 36129f21b86db4bd69e932e586129e246c2a5ca8 but isn't useful anymore as corresponding tests pass without it
* move id_before_type_cast to PrimaryKey moduleSergey Nartimov2012-02-162-6/+11
|
* Rename field_changed? to _field_changed? so that users can create a field ↵Akira Matsuda2012-02-141-3/+3
| | | | named field
* handle id attribute in PrimaryKey moduleSergey Nartimov2012-02-111-0/+6
|
* PG column consults oid types when typecastingAaron Patterson2012-02-101-0/+6
|
* removing dead codeAaron Patterson2012-02-093-22/+0
|
* Merge branch 'master' into instance_readerAaron Patterson2012-02-091-0/+8
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * master: (30 commits) Bump tzinfo. 0.3.31 was released on November 6, 2011. Fix GH #4909. Dependency on TZInfo move from AR to AS. moving ordered hash to normal hash because ruby 1.9.3 hash defaultly ordered one Refactored the OrderedHash related stuff Replaced OrderedHash usage with Ruby 1.9 Hash Replaced OrderedHash with Hash for ruby 1.9 series removed unnecessary code replacing the orderhash with hash for ruby-1.9 Clean up some wording. Fix typo. test title changed corresponding to the test replaced active support ordered hash to ruby hash on active resource PostgreSQL does not work in the same way of the other adapters AR::Relation#pluck: improve to work with joins Fix match docs Fix attribute_before_type_cast for serialized attributes. Fixes #4837. Fix failing request test Fixes in AMo README Update README to mention lint. Trim down Active Model API by removing valid? and errors.full_messages ...
| * Fix attribute_before_type_cast for serialized attributes. Fixes #4837.Jon Leighton2012-02-071-0/+8
| |
* | 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
| |