Skip to content

Fixes issue with unconvert case and alternative key during deserialize #71

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

Merged
merged 2 commits into from
May 3, 2019
Merged

Fixes issue with unconvert case and alternative key during deserialize #71

merged 2 commits into from
May 3, 2019

Conversation

alonewarrior
Copy link
Contributor

Fixes issue involving a targeted unconvert case and an alternative key wherein the alternative key could be reached due to a match for the unconverted case not existing.

This issue arose when the data to be deserialized was in a particular case (specified by the convert case), but it would not properly use the alternative key due to the relation key having not been unconverted yet.

Example:

      Serializer.register('articles', {
        unconvertCase: 'snake_case',
        relationships: {
          article_author: {
            alternativeKey: 'article_author_id',
            type: 'authors',
          },
        }
      });
      const data = {
        data: {
          type: 'article',
          id: '1',
          attributes: {
            createdAt: '2015-05-22T14:56:29.000Z'
          },
          relationships: {
            articleAuthor: {
              data: {
                type: 'people',
                id: '1'
              }
            }
          }
        }
      };

"articleAuthor" does not get deserialized to "article_author_id" in this particular case without these changes.

…y wherein the alternative key could be reached due to a match for the unconverted case not existing

Adds .idea to .gitignore

Updated version to 1.15.1
@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 0a74ef5 on alonewarrior:master into 3a36b33 on danivek:master.

2 similar comments
@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 0a74ef5 on alonewarrior:master into 3a36b33 on danivek:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 0a74ef5 on alonewarrior:master into 3a36b33 on danivek:master.

@coveralls
Copy link

coveralls commented May 2, 2019

Coverage Status

Coverage remained the same at 100.0% when pulling d555ffe on alonewarrior:master into 3a36b33 on danivek:master.

@danivek danivek merged commit 9af5c72 into danivek:master May 3, 2019
@danivek
Copy link
Owner

danivek commented May 3, 2019

@alonewarrior Thanks for the PR !

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 this pull request may close these issues.

3 participants