Closed zlwaterfield closed 3 years ago
I will close this for now, I haven’t experienced this since I opened it and I am not sure how it happened. If I see it again I will create a repo to replicate it.
Here were the ideas discussed on Slack, in case it gets reopened:
SupabaseService
indicates that you’re somehow adding filters to the query from some other area of your app before executing the call with select()
/ update() etc.What's the possible fix for this? I'm getting same 404
error on a Next.js app. I tried after yarn build
but same.
I'm having the same behaviour with update
method and I'm also using Next.js.
let { data: profiles, error } = await supabase
.from("profiles")
.select("*")
.eq("id", "f4a2d4dd-4aec-4af6-8ba9-9556be7349c3");
works fine.
But this does not (404 error):
let { data: profiles, error } = await supabase
.from("profiles")
.update({ username })
.eq("id", "f4a2d4dd-4aec-4af6-8ba9-9556be7349c3");
Having a 404 error. The endpoint is https://url.supabase.co/rest/v1/profiles?id=eq.f4a2d4dd-4aec-4af6-8ba9-9556be7349c3
Same here. I'm using "@supabase/supabase-js": "^1.24.0"
with Next.js.
This works.
const { data, error } = await supabase
.from('post_likes')
.select()
.match({ post_id: postId, account_id: accountId })
// console.log(data)
[
{
"postId": 1,
"accountId": 1,
"read": false
}
]
But this doesn't work.
const { data, error } = await supabase
.from('post_likes')
.update({
read: true,
})
.match({ post_id: postId, account_id: accountId })
// console.log(data, error)
null []
The response status of PUT /rest/v1/post_likes?post_id=eq.1&account_id=eq.1
is 404.
GET and DELETE methods are ok.
I solved this problem by myself. There was something wrong with the update policy.
create policy "Users can update their own like."
on comment_likes for update with check ( auth.role() = 'authenticated' );
I changed with check
to using
.
create policy "Users can update their own like."
on comment_likes for update using ( auth.role() = 'authenticated' );
Then, update
from JS works.
For anyone facing similar issues with other update queries, please note that
USING
INSERT
or UPDATE
are checked against the expression specified in WITH CHECK
https://www.postgresql.org/docs/current/sql-createpolicy.html
@AgarwalPragy You mean INSERT or UPSERT, right? I thought that UPDATE cannot add a new row.
@AgarwalPragy You mean INSERT or UPSERT, right? I thought that UPDATE cannot add a new row.
That is a little confusing actually. I just quoted the line direct from the postgres docs: https://www.postgresql.org/docs/current/sql-createpolicy.html
It explicitly says
... while new rows that would be created via INSERT or UPDATE are checked against the expression specified in WITH CHECK ...
Probably means "rows that are created as a side effect of the update operation" - in case of triggers for example.
Bug report
Describe the bug
I am running an update on a single row in the table
wedding
and it is 404ing. I've confirmed I am using the correct id and table. It seems the request being made is not correct.Here is the code:
The request url is:
If you break that down:
Why are both
neq
andeq
being applied and why isneq
there 4 times? Also, why is slug there? The slug was not included in the filter, just in the body.Screenshots
System information