Skip to content

serializedName not working when included in relationship #174

@jacobbullock

Description

@jacobbullock

** UPDATED WITH MORE DETAIL **

My model has a few attributes that are serialized

@Attribute({ serializedName: 'tier-1' })
tier1: number;

If i make a request to get this model, the serializedName is respected, but if I try to include that model as part of another request using the include parameter, the js console shows tier1 undefined, but shows tier-1 with the right value. same for createdAt (created-at), and updatedAt (updated-at)

Example Calls:

this.api.find(Classroom, '1', {include: 'performance_scale'}, (classroom: Classroom) => {
  console.log(classroom.performanceScale.tier1);     // undefined
  console.log(classroom.performanceScale['tier-1']); // 90
});

excerpt from inspecting the performance scale object in console
...
name:"Default"
tier1: undefined
tier2: undefined
tier3: undefined
tier4: undefined
tier-1: 90
tier-2: 80
tier-3: 70
tier-4: 60
...

this.api.find(PerformanceScale, '1', {include: ''}, (performanceScale: PerformanceScale) => {
  console.log(performanceScale.tier1);     // 90
  console.log(performanceScale['tier-1']); // undefined
});

excerpt from inspecting the performance scale object in console
...
name: "Default"
tier1: 90
tier2: 80
tier3: 70
tier4: 60
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions