Skip to content

Compiler should use normalizeCase function from Serializer #152

@jhliberty

Description

@jhliberty

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;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions