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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

currently failing on rails edge (6.1) #92

Closed
jrochkind opened this issue Jun 15, 2020 · 3 comments · Fixed by #93
Closed

currently failing on rails edge (6.1) #92

jrochkind opened this issue Jun 15, 2020 · 3 comments · Fixed by #93

Comments

@jrochkind
Copy link
Owner

jrochkind commented Jun 15, 2020

Looks like it may be particular to the new "single model serialized to json field" feature we just added in #89... they may have removed the feature we are using for this from Rails 6.1?? DOH!

Needs more investigation.

  1) AttrJson::Model with ActiveRecord serialize to one column will cast from hash
     Failure/Error: record_instance.other_attributes = embedded_model_attributes
     
     ArgumentError:
       wrong number of arguments (given 2, expected 1)
     # ./spec/single_serialized_model_attribute_spec.rb:58:in `block (2 levels) in <top (required)>'

  2) AttrJson::Model with ActiveRecord serialize to one column can assign and save from model class
     Failure/Error: record_instance.other_attributes = model_value
     
     ArgumentError:
       wrong number of arguments (given 2, expected 1)
     # ./spec/single_serialized_model_attribute_spec.rb:44:in `block (2 levels) in <top (required)>'
 
 3) AttrJson::Model with ActiveRecord serialize to one column with existing value can set to nil
     Failure/Error: let(:record_instance) { record_class.new(other_attributes: embedded_model_attributes)}
     
     ArgumentError:
       wrong number of arguments (given 2, expected 1)
     # ./spec/single_serialized_model_attribute_spec.rb:72:in `block (3 levels) in <top (required)>'
     # ./spec/single_serialized_model_attribute_spec.rb:75:in `block (3 levels) in <top (required)>'
@jrochkind
Copy link
Owner Author

This may actually be a bug in rails itself, breaking serialization with a custom coder or custom type.

Serialization tries to:

        if coder.respond_to?(:assert_valid_value)
          coder.assert_valid_value(value, action: "serialize")
        end

But then default assert_valid_value (which is no-op) now takes a single argument instead of a splat, so it calls it and raises....

Have to figure out how to reproduce with simple example to report to rails.... It might be reproducible with any custom Serialize on a jsonb column.

Why did the signature of default assert_valid_value change?

@jrochkind
Copy link
Owner Author

Why did the signature of default assert_valid_value change?

Looks like it was done in an unrelated commit, weird. rails/rails@d29d459

jrochkind added a commit that referenced this issue Jun 15, 2020
…el::Type

In master/Rails 6.1, they wind up with conflicting APIs. This is better OO design anyway, that was a mistaken shortcut, keep everything clear this way.

Resolves #92
@jrochkind
Copy link
Owner Author

Problem was that a Serialization "Coder" has a assert_valid_value with a different signature than an ActiveModel::Type. Trying to use the same object for both wound up colliding, we've separated them in #93 , better OO design anyway.

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

Successfully merging a pull request may close this issue.

1 participant