aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/attribute_methods
Commit message (Collapse)AuthorAgeFilesLines
* Refactor determination of whether the field has changedSean Griffin2014-06-032-35/+2
| | | | | The types know more about what is going on than the dirty module. Let's ask them!
* Remove most code related to serialized propertiesSean Griffin2014-06-013-58/+7
| | | | | | | | | | | 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
* Don't change values in `@raw_attributes` during serializationSean Griffin2014-06-011-1/+1
| | | | | | During `init_with`, the attributes given to the coder will be placed into `@raw_attributes`. As such, we should read from `@raw_attributes` when encoding, rather than `@attributes`, which has been type cast.
* Rename attribute related instance variables to better express intentSean Griffin2014-05-306-16/+16
| | | | | | | | | `@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.
* Don't reference comments that do not existSean Griffin2014-05-291-2/+0
|
* Move `type_cast_for_write` behavior over to the serialized type objectSean Griffin2014-05-292-48/+8
|
* Refactor serialized types to be partially defined as custom propertiesSean Griffin2014-05-291-20/+6
| | | | | | | Many of the methods defined in `AttributeMethods::Serialization` can be refactored onto this type as well, but this is a reasonable small step. Removes the `Type` class, and the need for `decorate_columns` to handle serialized types.
* Add an interface for type objects to control Ruby => SQLSean Griffin2014-05-262-8/+4
| | | | | Adds the ability to save custom types, which type cast to non-primitive ruby objects.
* Merge pull request #14613 from Sirupsen/fix-serialize-update-columnRafael Mendonça França2014-05-212-14/+30
|\ | | | | | | | | | | | | Fix serialized field returning serialized data after update_column Conflicts: activerecord/CHANGELOG.md
| * Fix serialized field returning serialized data after update_columnSimon Eskildsen2014-04-052-14/+30
| |
* | Remove :timestamp column typeSean Griffin2014-05-192-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | 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`.
* | docs, double meaning of `serialize` argument. Closes #14284.Yves Senn2014-04-141-5/+16
|/ | | | | | | | The second argument to serialize has double meaning: * `class_name` of the Type to serialize * `coder` to use then serializing. The new variable name and the docs better describe that behavior.
* [Active Record] Renamed private methods create_record and update_recordPrathamesh Sonpatki2014-02-201-2/+2
| | | | | | 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
* AestheticRafael Mendonça França2014-01-291-6/+5
|
* Fixing issue with activerecord serialization not being able to dump a record ↵Mauricio Linhares2014-01-291-0/+11
| | | | after loading it from YAML - fixes #13861
* Merge pull request #13799 from kbrock/better_dirtyJeremy Kemper2014-01-222-1/+29
|\ | | | | Better ActiveRecord hierarchy for Dirty and others
| * Move changed_attributes into dirty.rbKeenan Brock2014-01-222-1/+29
| | | | | | Move serialization dirty into serialization.rb
* | Add more tests for the dirty feature for enumsRafael Mendonça França2014-01-211-1/+0
| |
* | Extract all attribute changed work to its own methodRafael Mendonça França2014-01-211-3/+7
|/ | | | This will make easier to hook on this feature to customize the behavior
* Fix typo: data --> dateAlex Ghiculescu2013-12-191-1/+1
|
* Merge branch 'master' of github.com:rails/docrailsVijay Dev2013-11-071-0/+3
|\
| * warning about saving models with dirty attributesDamien Mathieu2013-10-231-0/+3
| | | | | | | | See #8328
* | `ActiveRecord::Store` works together with PG `hstore` columns.Yves Senn2013-10-251-0/+4
|/ | | | | | This is necessary because as of 5ac2341 `hstore` columns are always stored as `Hash` with `String` keys. `ActiveRecord::Store` expected the attribute to be an instance of `HashWithIndifferentAccess`, which led to the bug.
* Merge pull request #10816 from bogdan/less-dirty-dirtyRafael Mendonça França2013-09-231-9/+6
| | | | Make AM::Dirty less dirty to plugin into AR or other library
* Merge pull request #12188 from SamSaffron/masterAaron Patterson2013-09-111-7/+8
|\ | | | | Perf: avoid dupes add fallback logic for coders
| * Perf: avoid dupes add fallback logic for codersSam2013-09-111-7/+8
| |
* | Perf: avoid array allocation where not neededSam2013-08-271-1/+1
|/
* method transplanting between modules isn't supported on 1.9Aaron Patterson2013-07-032-10/+51
|
* refactor the method cache objects to have a superclassAaron Patterson2013-07-032-51/+16
|
* keep a cache of writer methodsAaron Patterson2013-07-031-11/+34
|
* 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-022-4/+6
|
* eagerly assign the attribute name cache, remove const_missingAaron Patterson2013-07-022-0/+4
|
* Removed deprecated methods partial_updates and familyNeeraj Singh2013-07-021-11/+0
| | | | | Removed deprecated methods `partial_updates`, `partial_updates?` and `partial_updates=`
* fix serialization type cast when value is already unserializedJan Berdajs2013-06-051-1/+5
|
* the typecast value should be passed to the serializer. fixes #10830Aaron Patterson2013-06-051-5/+5
|
* Remove instance level serialized_attributes setting was deprecated.kennyj2013-06-021-7/+0
|
* read_attribute_before_type_cast should accept symbolNeeraj Singh2013-05-111-1/+2
|
* fix :nodoc: mark on AR::AttributeMethods::Serialization [ci skip]Francesco Rodriguez2013-04-121-2/+2
|
* update ActiveRecord::AttributeMethods::Serialization documentation [ci skip]Francesco Rodriguez2013-04-041-0/+7
|
* safely publish columns and columns hash infoAaron Patterson2013-03-141-1/+1
|
* assigning '0.0' to a nullable numeric column does not make it dirtyYves Senn2013-03-051-1/+5
|
* Reduced memory leak problem in transactions by lazily updating AR objects ↵wangjohn2013-02-201-0/+5
| | | | with new transaction state. If AR object has a callback, the callback will be performed immediately (non-lazily) so the transaction still has to keep records with callbacks.
* Gist URLs are now namespacedAkira Matsuda2013-02-181-1/+1
| | | | see: https://github.com/blog/1406-namespaced-gists
* Simplify type casting code for timezone aware attributesAndrew White2013-01-261-10/+5
| | | | | | With the addition of String#in_time_zone and Date#in_time_zone we can simplify the type casting code by checking if the value has an `in_time_zone` method.
* Fix handling of dirty time zone aware attributesLilibeth De La Cruz2013-01-261-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Previously, when `time_zone_aware_attributes` were enabled, after changing a datetime or timestamp attribute and then changing it back to the original value, `changed_attributes` still tracked the attribute as changed. This caused `[attribute]_changed?` and `changed?` methods to return true incorrectly. Example: in_time_zone 'Paris' do order = Order.new original_time = Time.local(2012, 10, 10) order.shipped_at = original_time order.save order.changed? # => false # changing value order.shipped_at = Time.local(2013, 1, 1) order.changed? # => true # reverting to original value order.shipped_at = original_time order.changed? # => false, used to return true end
* Revert "Round usec when writing timestamp attribute."Andrew White2013-01-221-13/+5
| | | | | | | | | | This reverts commit e9d2ad395ec2ef929d74752f3d71c80674044fbe. Closes #8460 Conflicts: activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb activerecord/test/cases/dirty_test.rb