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

Compiler should use normalizeCase function from Serializer #152

Open
jhliberty opened this issue Aug 17, 2017 · 1 comment
Open

Compiler should use normalizeCase function from Serializer #152

jhliberty opened this issue Aug 17, 2017 · 1 comment

Comments

@jhliberty
Copy link

Currently, when constructing the queries to send to the server, the compiler uses the adapters normalizeCase function. If the server is sending attributes underscored and ember expects them camelCased, overwriting the normalizeCase function in the adapter will cause the query to succeed but multi-word attributes to not display in the ember app. To get it working I had to do something like the following in my adapter:

compile(store, type, options) {
    options['normalizeCaseFn'] = this.compileNormalizeCase;
    return Compiler.compile(type, store, options);
  },
  compileNormalizeCase: function(string) {
    return underscore(string);
  }

and in the serializer:

normalizeCase(string) {
    return underscore(string);
  }

Since the normalizeCase function in the serializer is what is normally expected to be sent to the server and the normalizeCase on the adapter is used for retrieving data from the server it would make more sense to use the serializers normalizeCase function instead of the adapters.

options['normalizeCaseFn'] = this.normalizeCase;

@delkopiso
Copy link
Contributor

@jhliberty can you provide an example of the data being sent by the server and the model that's being deserialized from it?

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