Git Product home page Git Product logo

Comments (9)

KushibikiMashu avatar KushibikiMashu commented on May 18, 2024 47

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.

AgarwalPragy avatar AgarwalPragy commented on May 18, 2024 16

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 or UPDATE are checked against the expression specified in WITH CHECK

https://www.postgresql.org/docs/current/sql-createpolicy.html

from supabase-js.

zlwaterfield avatar zlwaterfield commented on May 18, 2024 1

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.

kiwicopple avatar kiwicopple commented on May 18, 2024 1

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 with select() / update() etc.
  • could be caused by an auto-reloading dev environment and that is somehow caching the filters each reload

from supabase-js.

surjithctly avatar surjithctly commented on May 18, 2024

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.

KevTale avatar KevTale commented on May 18, 2024

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.

KushibikiMashu avatar KushibikiMashu commented on May 18, 2024

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.

EskelCz avatar EskelCz commented on May 18, 2024

@AgarwalPragy You mean INSERT or UPSERT, right? I thought that UPDATE cannot add a new row.

from supabase-js.

AgarwalPragy avatar AgarwalPragy commented on May 18, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.