-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
fix incorrect belongs_to serialization when foreign_key on object and belongs_to is blank #2337
fix incorrect belongs_to serialization when foreign_key on object and belongs_to is blank #2337
Conversation
Had a quick try but can't get
|
is this up for discussion? (it's blocking the PR)
|
I think it should be enough to make this test pass according to json_api specification. def test_for_type_with_id_given_blank_id
id = ''
actual = ResourceIdentifier.for_type_with_id('admin_user', id, {})
assert_nil actual
end In order to do that, we simply need to return I tested it locally and all tests ran successfully along with the rubocop linter. |
@wasifhossain looks good, are you going to make a PR? |
@InteNs I think you are better equipped to test my proposed changes in your codebase and if you find it working, then take your time to update this PR. After that, we will take another look and merge if none of us find any issues with it |
1528241
to
41f699f
Compare
aye, will test my fork in our staging environment |
41f699f
to
28a172e
Compare
tested this on staging over here and it's working fine. |
great to know 🙌 thanks for your help! unfortunately we are having this issue with |
we are experiencing the same issue and downgraded the gem to |
I also think we can restrict the @InteNs can you please make a small tweak in active_model_serializers.gemspec#L45 to update the upper bound to
|
@bf4 do you have any other suggestions? thanks |
the failing travis run seems to be a problem outside of this PR? Also, since nothing has been released since february, Can I expect there to be a release soon after this merge? |
@InteNs can you put a changelog entry to summarize the change this PR would bring? thanks! |
jsonapi-rb/jsonapi-renderer#38 has been merged and jsonapi-renderer updated to 0.2.2. Try new version. |
This reverts commit 58f4f98.
looks like let's remove that single space from render json: [@post], adapter: :json_api, include: 'author,comments' Ref: Include Doc |
@@ -82,7 +82,7 @@ def render_collection_without_include | |||
|
|||
def render_collection_with_include | |||
setup_post | |||
render json: [@post], adapter: :json_api, include: 'author, comments' | |||
render json: [@post], adapter: :json_api, include: 'author,comments' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note for future reference:
this change belongs to jsonapi-rb/jsonapi-renderer#38 only, irrelevant of this PR. we need to make this tweak according to the include doc in order to make the test suite pass.
all tests are green again 🙌 I think we can merge it now |
Changes
ResourceIdentifier will return nil instead of a hash when the association foreign_key is blank
and
jsonapi_use_foreign_key_on_belongs_to_relationship = true
Caveats
- locksjsonapi-renderer
to< 0.2.1
untill jsonapi-rb/jsonapi-renderer#38 gets solvedRelated GitHub issues
related #2335
Additional helpful information