Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken defaults in 2.0 #147

Closed
colszowka opened this issue May 8, 2023 · 2 comments
Closed

Broken defaults in 2.0 #147

colszowka opened this issue May 8, 2023 · 2 comments

Comments

@colszowka
Copy link

Hi 馃憢

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:

# Gemfile
source "https://rubygems.org"

gem "activerecord"
gem "sqlite3"
gem "store_model", "~> 2.0"
# 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.

@DmitryTsepelev
Copy link
Owner

Should be fine now, making new release

@colszowka
Copy link
Author

@DmitryTsepelev Thank you for the quick update, I can confirm it works again now 馃憤

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants