aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record.rb
diff options
context:
space:
mode:
authorSean Griffin <sean@seantheprogrammer.com>2016-07-25 11:06:04 -0400
committerSean Griffin <sean@seantheprogrammer.com>2016-07-25 11:12:06 -0400
commitf0ddf87e4bfcfcb861b0a9dca32edb733668bd30 (patch)
tree37e30078178423e3b7f8850ab7b667f70db9abfc /activerecord/lib/active_record.rb
parent7ebef567ce30d848dd8f9374fd70699fd91acb29 (diff)
downloadrails-f0ddf87e4bfcfcb861b0a9dca32edb733668bd30.tar.gz
rails-f0ddf87e4bfcfcb861b0a9dca32edb733668bd30.tar.bz2
rails-f0ddf87e4bfcfcb861b0a9dca32edb733668bd30.zip
Correct the behavior of virtual attributes on models loaded from the db
Previously we had primarily tested the behavior of these attributes by calling `.new`, allowing this to slip through the cracks. There were a few ways in which they were behaving incorrectly. The biggest issue was that attempting to read the attribute would through a `MissingAttribute` error. We've corrected this by returning the default value when the attribute isn't backed by a database column. This is super special cased, but I don't see a way to avoid this conditional. I had considered handling this higher up in `define_default_attribute`, but we don't have the relevant information there as users can provide new defaults for database columns as well. Once I corrected this, I had noticed that the attributes were always being marked as changed. This is because the behavior of `define_default_attribute` was treating them as assigned from `Attribute::Null`. Finally, with our new implementation, `LazyAttributeHash` could no longer be marshalled, as it holds onto a proc. This has been corrected as well. I've not handled YAML in that class, as we do additional work higher up to avoid YAML dumping it at all. Fixes #25787 Close #25841
Diffstat (limited to 'activerecord/lib/active_record.rb')
0 files changed, 0 insertions, 0 deletions