Skip to content

falsy JavaScript attribute values are getting set to null if nullIfMissing flag is set #241

@hinsenchan

Description

@hinsenchan

I was trying to set nulls for missing attributes for a boolean and number attribute where the values are false and 0 respectively. The serializer converted them to nulls because of the falsy value comparison. I believe it is caused by the two lines below...anyone else experience the same thing?

jsonapi-serializer/lib/serializer-utils.js 

line 201 !dest[attr]
line 295 !record[attribute]

I think the fix is likely relatively simple since we're already using Lodash if we can agree missing means undefined?

jsonapi-serializer/lib/serializer-utils.js 

line 201 isUndefined(dest[attr])
line 295 isUndefined(record[attribute])

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