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

Nested Resource foreign key parsed as string #925

Open
jasonlimantoro opened this issue Mar 2, 2019 · 8 comments
Open

Nested Resource foreign key parsed as string #925

jasonlimantoro opened this issue Mar 2, 2019 · 8 comments

Comments

@jasonlimantoro
Copy link

jasonlimantoro commented Mar 2, 2019

When doing a POST request to create a new nested resource, its foreign key is parsed as string, as opposed to integer. This causes the parent to not recognize its child resource.

For example

POST /posts/1/images

BODY
{
    url: ‘some-url’
}

would yield a response

{
    url: ‘some-url’,
    postId: “1”,
    id: 1
}

So, when doing a GET request
GET /posts/1?_embed=images, the response is as follows

{
    id: 1,
    ...,
    images : [],
}

Essentially, the post doesn’t recognize the image attached to it, because the foreign key is parsed as string.

Manually changing the foreign key into integer data type will work.

Any suggestion? Is this how it’s supposed to work?

Some existing comments that I found

b4dnewz pushed a commit to codekraft-studio/json-server that referenced this issue Mar 9, 2019
Threat the request param as integer
closes typicode#925, closes typicode#396
b4dnewz pushed a commit to codekraft-studio/json-server that referenced this issue Mar 19, 2019
Threat the request param as integer
closes typicode#925, closes typicode#396
@wilgert
Copy link

wilgert commented Aug 15, 2019

Can this one be merged? We suffer from the same problem!

@STotev
Copy link

STotev commented Oct 29, 2019

Same here. It's kind of a blocker when you are trying to mock POST methods.

@underGhost
Copy link

Hoping this could get merged as well!

@iluvmemes
Copy link

Would be great if we could get this merged.

@mancioshell
Copy link

Any update on this?

@arig2a
Copy link

arig2a commented Nov 22, 2021 via email

@skitband
Copy link

skitband commented Oct 4, 2022

any update with this?

@Polkasa
Copy link

Polkasa commented Dec 13, 2022

@typicode three years are passed and this issue is still not fixed :( . Can you merg this?

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

9 participants