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

Model property name clashes with json keys if using different formats #1331

Closed
thejuan opened this issue May 14, 2019 · 3 comments
Closed

Model property name clashes with json keys if using different formats #1331

thejuan opened this issue May 14, 2019 · 3 comments

Comments

@thejuan
Copy link
Contributor

thejuan commented May 14, 2019

Changes for #1089 mean that we can't have a property on the model that matches a key on a json field, but uses a different naming standard.

If we update the issue example to include a property with the same name as a json key it continues to alter the json key when it shouldn't. Example below.

I'd suggest modifying keyMapper to split on : and only map the left-handside

 TestModel.query()
        .patch({
          firstName: "Sue",
          "jsonColumn:[0][first_name]": "John",
        })


// Database output
{
  first_name: "Sue",
  json_column: '[{"firstName": "John"}]' 
}

@thejuan thejuan closed this as completed May 14, 2019
@thejuan thejuan changed the title Model property name clashes with json keys Model property name clashes with json keys if using different formats May 14, 2019
@thejuan thejuan reopened this May 14, 2019
@thejuan
Copy link
Contributor Author

thejuan commented May 14, 2019

Happy to submit PR for change to keyMapper function

@koskimas koskimas reopened this May 14, 2019
@koskimas
Copy link
Collaborator

We cannot change the keyMapper. The keys are handled that way because : is used as a separator with joinEager nested relations too. That's a design flaw I'd like to address in objection 2.0. I'll probably revert #1089 because it's causing more problems than it's fixing.

@koskimas
Copy link
Collaborator

Fix for 1089 has been reverted. The next patch release will contain the fix.

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