cloudcreativity / laravel-json-api

JSON API (jsonapi.org) package for Laravel applications.
http://laravel-json-api.readthedocs.io/en/latest/
Apache License 2.0
780 stars 109 forks source link

Invalid text representation error when trying give string to integer key #574

Closed bbprojectnet closed 3 years ago

bbprojectnet commented 3 years ago

Hi,

I have primary key as a integer.

When i try this: PATCH /api/quizzes/999999999 i get not found response - it's ok.

But, when i try this: PATCH /api/quizzes/somestring i get error 500 - "Invalid text representation".

It happend on PostgreSQL database which is very strict and throw error when we try select * from "quizzes" where "quizzes"."id" = somestring.

lindyhopchris commented 3 years ago

Yeah, you don't want the somestring to even hit your database, which is why you should use ID constraints: https://laravel-json-api.readthedocs.io/en/latest/basics/routing/#id-constraints

bbprojectnet commented 3 years ago

Thanks a lot!