aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/persistence.rb
Commit message (Collapse)AuthorAgeFilesLines
...
* | Go through normal where logic in destroySean Griffin2015-01-141-9/+1
| | | | | | | | | | | | Building the Arel AST, and manipulating the relation manually like this is prone to errors and breakage as implementation details change from underneath it.
* | Deprecate `false` as the way to halt AR callbacksclaudiob2015-01-021-14/+14
| | | | | | | | | | | | | | | | | | | | Before this commit, returning `false` in an ActiveRecord `before_` callback such as `before_create` would halt the callback chain. After this commit, the behavior is deprecated: will still work until the next release of Rails but will also display a deprecation warning. The preferred way to halt a callback chain is to explicitly `throw(:abort)`.
* | Add doc for `:touch` option of AR::Base#saveclaudiob2014-12-301-0/+8
| | | | | | | | | | | | | | | | | | ActiveRecord::Base `save` and `save!` take an option boolean `:touch` parameter since #18225 (stems from #18202). This commit document that parameter. [ci skip]
* | Provide :touch option to save() to accommodate saving without updating ↵Dan Olson2014-12-271-6/+6
| | | | | | | | timestamps. [#18202]
* | Correct grammar to fix #18182 [ci skip]Zachary Scott2014-12-241-1/+1
| |
* | document that `.delete` does work on `#readonly?` records. Closes #11860Yves Senn2014-12-031-0/+2
| | | | | | | | | | | | | | | | [ci skip] This is due to the fact that `.delete` is directly translated to SQL. It tries to follow the same rules as `.delete_all` which is not able to verify that records are `#readonly?`.
* | Fix a bug where AR::RecordNotSaved loses error messagesYuki Nishijima2014-11-271-1/+1
| | | | | | | | | | | | Since 3e30c5d, it started ignoring the given error message. This commit changes the behavior of AR::RecordNotSaved#initialize so that it no longer loses the given error message.
* | Add #record attribute to RecordNotFound and RecordDestroyed exceptions.Recursive Madman2014-11-261-2/+2
| | | | | | | | This allows these exceptions to be handled generically in conjunction with RecordInvalid.
* | Remove the unused second argument to `substitute_at`Sean Griffin2014-11-171-1/+1
| | | | | | | | Oh hey, we got to remove some code because of that!
* | Revert "Improve performance of AR object instantiation"Sean Griffin2014-11-141-25/+3
| | | | | | | | | | | | | | | | | | | | This reverts commit 8fee923888192a658d8823b31e77ed0683dfd665. Conflicts: activerecord/lib/active_record/attribute_set/builder.rb This solution sucks, and is hard to actually apply across the board. Going to try other solutions
* | Print out a meaningful error when ActiveRecord::ReadOnlyRecord is raisedFranky W2014-11-061-2/+2
| | | | | | | | | | | | | | Currently, there is no messages which get printed out. Convoluted system may have hooks that create other objects in which case we only fail with no messages. This commit changes this information allowing you to know which object is the one that actually raised the error.
* | Improve performance of AR object instantiationSean Griffin2014-11-051-3/+25
|/ | | | | | | We introduced a performance hit by adding an additional iteration through a model's attributes on creation. We don't actually need the values from `Result` to be a hash, we can separate the columns and values and zip them up ourself during the iteration that we have to do.
* Implement `_was` and `changes` for in-place mutations of AR attributesSean Griffin2014-08-161-1/+1
|
* update error message to reflect that the record could have been destroyedlsylvester2014-08-111-1/+2
|
* Rephrase how we explain RecordInvalid exception in the context ofZachary Scott2014-08-071-3/+5
| | | | | | `#create!` regarding validations in contrast to the behavior of `#create`. Also describe creating multiple objects using an array of hashes as the +attributes+ parameter. [ci skip] /cc #16384
* [ci skip] Updated create! documentation description and added +attributes+ ↵Tom Kadwill2014-08-071-2/+5
| | | | for rdoc
* Moved #create! method from Validations to Persistence moduleBogdan Gusiev2014-08-051-0/+12
|
* After find-via-reload, the record is not newMatthew Draper2014-07-051-0/+1
|
* Remove unneeded `@column_types` instance variableSean Griffin2014-06-221-2/+0
| | | | This was used more previously, but other uses have been removed.
* `reload` should fully reload attributesSean Griffin2014-06-221-1/+1
| | | | | | `reload` is meant to put a record in the same state it would be if you were to do `Post.find(post.id)`. This means we should fully replace the attributes hash.
* Introduce an object to aid in creation and management of `@attributes`Sean Griffin2014-06-191-5/+1
| | | | | Mostly delegation to start, but we can start moving a lot of behavior in bulk to this object.
* Remove unused column types overrideSean Griffin2014-06-131-8/+2
|
* Introduce an Attribute object to handle the type casting danceSean Griffin2014-06-131-4/+8
| | | | | | | | | | | | | | | There's a lot more that can be moved to these, but this felt like a good place to introduce the object. Plans are: - Remove all knowledge of type casting from the columns, beyond a reference to the cast_type - Move type_cast_for_database to these objects - Potentially make them mutable, introduce a state machine, and have dirty checking handled here as well - Move `attribute`, `decorate_attribute`, and anything else that modifies types to mess with this object, not the columns hash - Introduce a collection object to manage these, reduce allocations, and not require serializing the types
* No need to decorate columns twiceSean Griffin2014-06-101-1/+0
| | | | | | | We never want result types to override column types, and `decorate_columns` can only affect column types. No need to go through the decoration multiple times, we can just exclude the column types from the result types instead.
* Remove duplicated `@raw_attributes.keys`Sean Griffin2014-06-071-2/+2
| | | | | Reduces the number of things outside of attribute methods that cares about the details of how we store and type cast attributes
* Bring type casting behavior of hstore/json in line with serializedSean Griffin2014-06-041-1/+1
| | | | | `@raw_attributes` should not contain the type-cast, mutable version of the value.
* New records should remain new after yaml serializationSean Griffin2014-06-011-1/+5
|
* Rename attribute related instance variables to better express intentSean Griffin2014-05-301-5/+5
| | | | | | | | | `@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.
* docs, `instantiate` expects `String` keys. [Rafal Piekarski & Yves Senn]Yves Senn2014-05-201-4/+4
| | | | | Closes #15122 Closes #15107
* Merge pull request #11650 from prathamesh-sonpatki/renameRafael Mendonça França2014-04-041-4/+4
|\ | | | | | | Renamed private methods _create_record and _update_record
| * [Active Record] Renamed private methods create_record and update_recordPrathamesh Sonpatki2014-02-201-4/+4
| | | | | | | | | | | | This is to ensure that they are not accidentally called by the app code. They are renamed to _create_record and _update_record respectively. Closes #11645
* | Merge pull request #14390 from huoxito/true-touchRafael Mendonça França2014-03-251-0/+2
|\ \ | | | | | | | | | Still touch associations when theres no timestamp
| * | Still touch associations when theres no timestampWashington Luiz2014-03-141-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | Prior to Rails 4.0.4 when touching a object which doesn't have timestamp attributes (updated_at / updated_on) rails would still touch all associations. After 73ba2c14cd7d7dfb2d132b18c47ade995401736f it updates associations but rollsback because `touch` would return nil since there's no timestamp attribute
* | | Improve touch docs with extra attributes passed in [ci skip]Carlos Antonio da Silva2014-03-201-5/+7
| | |
* | | ActiveRecord#touch should accept multiple attributes #14423Thiago Pinto2014-03-191-2/+3
| | |
* | | Update callbacks executed on AR::Base#touch [skip ci]Washington Luiz2014-03-141-2/+2
|/ / | | | | | | | | As of https://github.com/rails/rails/pull/12031 after_commit and after_rollback are also executed
* | Enhance docs for update_attribute [ci-skip]Mohamed Wael Khobalatte2014-03-121-0/+2
| |
* | Replace "data store" with database [ci skip]Robin Dupret2014-02-271-1/+1
|/ | | | Active Record is specifically for databases. Refs #12101.
* Correctly send the string given to lock! and reload(:lock) to the lock scope ↵Mauricio Linhares2014-01-291-1/+1
| | | | | | - fixes #13788 As per the documentation at lock!, if the :lock option is a string it should use the given SQL to generate the lock statement.
* fix bug in becomes! when changing from base to subclass. Closes #13272.Yves Senn2014-01-131-1/+5
|
* Change all "can not"s to the correct "cannot".T.J. Schuck2014-01-031-2/+2
|
* setting `changed_attributes` instance variable if it is already initialized.Kuldeep Aggarwal2013-12-281-1/+1
|
* Merge pull request #13474 from jdelStrother/becomesYves Senn2013-12-271-0/+1
|\ | | | | Copy changed_attributes across to newly become'd records
| * Copy changed_attributes across to newly become'd recordsJonathan del Strother2013-12-271-0/+1
| | | | | | Without this, the original record's values won't get saved, since the partial insertions support (https://github.com/rails/rails/commit/144e8691cbfb8bba77f18cfe68d5e7fd48887f5e) checks for changed values and thinks there are none.
* | Typo rectified commom => common[ci skip]Aayush khandelwal2013-12-251-1/+1
|/
* [ci skip]removed obsolete information about `options` parameter in create methodKuldeep Aggarwal2013-11-271-3/+0
|
* Add documentation for after_touch [ci skip]claudiob2013-10-081-1/+2
|
* improving `reload` doc wording. #12418 [ci skip]Yves Senn2013-10-021-1/+2
|
* Update AR reload doc for the case of manually set primary key attribute [ci ↵Anatoli Makarevich2013-10-021-2/+11
| | | | skip]
* Merge pull request #10816 from bogdan/less-dirty-dirtyRafael Mendonça França2013-09-231-1/+1
| | | | Make AM::Dirty less dirty to plugin into AR or other library