It seems that the changes from #146 broke handling of defaults in version 2.0. I noticed this from our test suite breaking, but here's an isolated test case:
# example.rb
require "bundler"
Bundler.require :default
ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":memory:"
ActiveRecord::Migration.create_table :users do |t|
t.string :email, null: false
t.text :settings, null: false, default: "{}"
end
class User < ActiveRecord::Base
class Settings
include StoreModel::Model
attribute :something, :boolean, default: false
end
attribute :settings, Settings.to_type
end
pp User.new.settings
On store_model 1.6.2: #<User::Settings something: false>
On store_model 2.0.0: #<User::Settings something: nil>
So it looks to me like the adjustments to serialization in #146 made it so that the default defined on the attribute is getting ignored now. Maybe it was also due to some other change, but I only saw this PR being mentioned on the changelog and on the surface it does seem like something that might have caused this issue.
Hi :wave:
It seems that the changes from #146 broke handling of defaults in version 2.0. I noticed this from our test suite breaking, but here's an isolated test case:
#<User::Settings something: false>
#<User::Settings something: nil>
So it looks to me like the adjustments to serialization in #146 made it so that the default defined on the attribute is getting ignored now. Maybe it was also due to some other change, but I only saw this PR being mentioned on the changelog and on the surface it does seem like something that might have caused this issue.