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

Revert .is_a?(JSON::Any) #262

Merged
merged 1 commit into from
Jul 23, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/granite/fields.cr
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ module Granite::Fields
when "{{_name.id}}"
if "{{_name.id}}" == "{{PRIMARY[:name]}}"
{% if !PRIMARY[:auto] %}
@{{PRIMARY[:name]}} = value.is_a?(JSON::Any) ? value.raw.as({{PRIMARY[:type]}}) : value.as({{PRIMARY[:type]}})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you provide a better explanation? Why do the other types not need it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was added in #221 to parse the primary key value from JSON::Any.

Since we are using JSON::Serializable now, we don't define our own .from_json thus JSON::Any never reaches this anymore.

This should have been changed back in #253 with the removal of the rest of the JSON::Any typings, but i missed this one.

@{{PRIMARY[:name]}} = value.as({{PRIMARY[:type]}})
{% end %}
return
end
Expand Down