Skip to content

Potential Bug Serializing Id's? #363

Closed
@RKennedy9064

Description

@RKennedy9064

I've been messing around with JsonApiDotNetCore a lot recently and encountered something strange. For some reason the database I'm working with has some tables where the Primary Key starts at 0 and I'm noticing some strange results. For any row where the Id is 0, it looks like it's not serializing the Id with the response. Is this intended behavior, or am I doing something wrong? For example, here is my request and response for an id of 1.

http://localtest.me:5000/api/v1/case-status-classes/1
{"data":{"attributes":{"label":"Pending","i18n-tag":null,"order-by":2},"type":"case-status-classes","id":"1"}}

and here is my request and response for an id of 0.

http://localtest.me:5000/api/v1/case-status-classes/0
{"data":{"attributes":{"label":"No Action","i18n-tag":null,"order-by":1},"type":"case-status-classes","id":""}}

It's able to find the case-status-class in the database with an Id of 0, but for some reason it's not sending the Id back with the response. When trying to bind my models in Ember it's giving me issues since there's no id.

"Assertion Failed: You must include an 'id' for case-status-class in an object passed to 'push'"

Is this an actual issue with how JsonApiDotNetCore is sending data back, or is it a user error and I have something messed up in my configuration? Just figured I'd bring it up since I noticed it. Any help would be greatly appreciated.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions