Comments (9)
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.
from supabase-js.
For anyone facing similar issues with other update queries, please note that
- Existing table rows are checked against the expression specified in
USING
- New rows that would be created via
INSERT
orUPDATE
are checked against the expression specified inWITH CHECK
https://www.postgresql.org/docs/current/sql-createpolicy.html
from supabase-js.
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.
from supabase-js.
Here were the ideas discussed on Slack, in case it gets reopened:
- it could be caused by the way the library / code is set up -
SupabaseService
indicates that you’re somehow adding filters to the query from some other area of your app before executing the call withselect()
/ update() etc. - could be caused by an auto-reloading dev environment and that is somehow caching the filters each reload
from supabase-js.
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.
from supabase-js.
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
from supabase-js.
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.
from supabase-js.
@AgarwalPragy You mean INSERT or UPSERT, right? I thought that UPDATE cannot add a new row.
from supabase-js.
@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.
from supabase-js.
Related Issues (20)
- The 'cache' field on 'RequestInitializerDict' is not implemented - Cloudflare Workers HOT 23
- Extremely dangerous bug: Partial .rpc(...) execution when client is called from Next14 Server Actions. Breaks ACID guarantee.
- List all users (auth schema) not working with local environment HOT 2
- Cannot clear user phone number using `supabase.auth.admin.updateUserById` function HOT 2
- `supabase` client exposes schema details via hint and messages
- Code in supabase-js calls `getSession()`, which now throws a warning when using in combo with ssr HOT 27
- Typescript Types do not reflect new feature: .rpc() with GET #529
- Access data
- Moving for 2.40 to 2.41 or more crash HOT 2
- Execution error with pnpm HOT 2
- Intermittent empty fetch response HOT 1
- Data has no return type when using geojson()
- New auth error codes missing in error object
- auth.getUser() returns null user and AuthSessionMissingError in [email protected] HOT 2
- supabaseAuthClient.auth.getUser not working on v2.42.5 HOT 4
- Types incorrectly inferred as array on a single select query with multiple one to many joins to the same table HOT 2
- SVELTEKIT: Streaming queries causes error. HOT 4
- Range Error: Invalid array length when I am using count exact and lte method
- FK values are `undefined` with inconsistent behaviour
- Nextjs Compile Error With SupabaseJS ( Not Nextjs Error )
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from supabase-js.