Error while making a PATCH method call
See original GitHub issueI was looking to send atomic updates to my server and in doing so required a PATCH
call to be made. But the server returned the following error to the client (with errorhandler
on).
{
"name": "GeneralError",
"message": "column \"id\" does not exist",
"code": 500,
"className": "general-error",
"data": {},
"errors": {}
}
Without errorhandler
this was the error printed on the server console.
SequelizeBaseError: column "id" does not exist
at Query.formatError (D:\code\playground\core-playground\feathers\node_modules\sequelize\lib\dialects\postgres\query.js:357:14)
at Query.<anonymous> (D:\code\playground\core-playground\feathers\node_modules\sequelize\lib\dialects\postgres\query.js:88:19)
Now I was able to make GET
PUT
calls to the server no problem. But it’s only during PATCH
is when I’m facing this issue. And I am a bit confused sue to that reason, because PUT
must take similar arguments as PATCH
.
Any way to diagnose it further?
One possibility is that my primary key in the resource is not named id
rather custom named as xyz_id
, if this is the issue in fact then any way I can use a hook to pre-process the data and make the patch method work? And also shouldn’t this simply work out of the box given the id
is already present in the URL to which the call is made /db/:resource/:id
and there should be no reliance on the primary key being named id
.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:11 (4 by maintainers)
Top GitHub Comments
I still think using the primary key of the model as the
id
property by default is a valuable change. So let’s keep this open.I think the reason is that
get
,update
andremove
usefindById
wherepatch
does not. We’ll need a way to get the name of the primary key field from the model and then use that forpatch
as well.