https://supabase.com/ logo
Join Discord
Powered by
# sql
  • k

    kresimirgalic

    01/07/2022, 3:36 PM
    return type mismatch in function declared to return feed
  • f

    florian-lefebvre

    01/07/2022, 4:53 PM
    Hi, I don't know how to tackle my current problem. First of all, here is my current schema:
    Copy code
    pgsql
    create table categories (
      id bigint generated by default as identity,
      title varchar not null,
      parent_id bigint references categories (id),
    
      primary key (id),
      unique (title)
    );
    
    create table resources (
      id bigint generated by default as identity,
      title varchar not null,
      url varchar not null,
      description varchar not null,
      date timestamp with time zone,
      author varchar not null,
    
      primary key (id)
    );
    
    create table categories_to_resources (
      id bigint generated by default as identity,
      category_id bigint references categories (id),
      resource_id bigint references resources (id),
    
      primary key (id)
    );
    As you can see in
    categories
    , the
    parent_id
    refers to another category. So here is what I want to achieve: on the frontend, i need to know if a category with
    id
    = X is empty, i.e. if it has subcategories or resources. So I need to check how many
    categories
    there are with
    parent_id
    = X and how many
    resources_to_categories
    have
    category_id
    = X. But I don't wan't to add another request from the frontend so I thought I could add it as a sql statement in a column or in a view to get the following:
    Copy code
    text
    CATEGORIES
    id | title | parent_id | count
    autogenerated | user provided | user provided | sum of 2 counts (the ones I talked above)
    How can I achieve that?
  • k

    kresimirgalic

    01/07/2022, 5:36 PM
    Hey did anyone got this error message on rpc? hint: "If a new foreign key between these entities was created in the database, try reloading the schema cache." message: "Could not find a relationship between pgrst_source and creator_ref in the schema cache"
    k
    s
    • 3
    • 3
  • k

    ktosiek

    01/07/2022, 6:20 PM
    missing relationship
  • t

    TremalJack

    01/07/2022, 7:44 PM
    Hello guys yesterday I create a new function, named: "match_user_for_what_they_are_looking" (short name I know lmao) anyway... the function work on db, work on supabase studio sql editor but if I try to run it via spuabase.rpc I get: "If a new function was created in the database with this name and parameters, try reloading the schema cache."
  • t

    TremalJack

    01/07/2022, 7:45 PM
    "Could not find the public.match_user_for_what_they_are_looking(var1,var2,var3) function or the public.match_user_for_what_they_are_looking function with a single unnamed json or jsonb parameter in the schema cache"
  • t

    TremalJack

    01/07/2022, 7:46 PM
    any idea how to fix?
  • g

    garyaustin

    01/07/2022, 8:36 PM
    You either are not calling the function with the same type and number of parameters, or you changed your function's parameters at some point which created additional functions with the same name.
  • b

    bent

    01/08/2022, 12:44 AM
    delete from auth.users where email like "%foo@mail.com";
    should this work? Trying to get rid of some test accounts from the UI right now
  • b

    bent

    01/08/2022, 12:44 AM
    I'm getting
    column "%foo@mail.com" does not exist
    as an error 🤔
  • b

    bent

    01/08/2022, 12:59 AM
    email needs to be cast to varchar via
    email:varchar
    instead of just
    email
    for this to work
  • t

    tourdownunder

    01/08/2022, 12:59 AM
    don't use double quotes
    "
    and use single
    '
    instead
  • b

    bent

    01/08/2022, 12:59 AM
    oh.
  • s

    stranger

    01/08/2022, 12:23 PM
    Hi guys. I am facing an issue trying to edit values before insert. I am using a trigger to handle this. Any help is appreciated. https://stackoverflow.com/questions/70626513/editing-values-before-inserting-a-row-supabase
  • f

    florian-lefebvre

    01/08/2022, 3:46 PM
    I managed to get what I wanted by using triggers
  • r

    razokulover

    01/09/2022, 9:36 AM
    I'm not sure if anyone has already mentioned this, but is there any documentation or articles with lots of working code for RLS?
    s
    • 2
    • 7
  • o

    oliviercp

    01/09/2022, 5:35 PM
    Hi! Is it safe to update the search() fonction on the storage schema? Because i would need to add a created_by column, but the search function with is used but the sdk list() function only returns predefined columns. Or is there another work around for this without having to edit the storage schema? Thanks!
    s
    • 2
    • 2
  • s

    silentworks

    01/10/2022, 9:23 AM
    RLS documentation
  • s

    silentworks

    01/10/2022, 9:29 AM
    Storage schema change
  • l

    logemann

    01/11/2022, 12:40 PM
    RAISE NOTICE and supabase logs
    c
    • 2
    • 18
  • c

    charles.morrow

    01/11/2022, 4:21 PM
    HI 👋 hopefully a simple query here. My RLS is based on a user id being in an auth table. If I say
    ((role() = 'authenticated'::text) AND (uid() = '057b1bc4-b79b-46ae'::uuid))
    it works but if i say
    ((role() = 'authenticated'::text) AND (uid() IN ( SELECT admin.user_uuid FROM admin)))
    it doesnt work there is a row with that user_uuid in the admin table. Can anyone see what im doing wrong? thanks!
    g
    m
    • 3
    • 4
  • m

    mattmatt

    01/11/2022, 5:58 PM
    I would love to store some html in a column in postgresql, but I've found that the XML datatype (https://www.postgresql.org/docs/current/datatype-xml.html) is too strict to parse bad html. I've tried a python based stored procedure that uses BeautifulSoup, but it felt too ugly for production. Anyone have experience with this sort of thing? Is there a way to relax the xml parser in postgresql?
    s
    • 2
    • 2
  • m

    mattmatt

    01/11/2022, 6:07 PM
    I'm imagining an api in postgresql that looks like this:
    select xpath((mypage::html), '//a/text()') from crawler.output
  • g

    garyaustin

    01/11/2022, 6:25 PM
    RLS issue with select on table
  • s

    silentworks

    01/11/2022, 7:56 PM
    Storing html into a table column
  • d

    Denzo

    01/12/2022, 2:36 PM
    Hey guys, I've got a question: I've got a table in the public schema with RLS enabled and I'd like for
    SELECT
    ,
    INSERT
    and
    UPDATE
    to be publically accessible with the Anon key, but only if the user knows either the
    deviceId
    or
    userId
    . I can't use
    auth().id
    because I want the API to be accessible even for users that have not yet registered. I just want people to prevent from querying the entire DB. How would I implement this using a policy?
    s
    g
    • 3
    • 3
  • j

    jaf

    01/12/2022, 2:38 PM
    I need help creating a row level security policy. I want to protect my
    products
    table. The
    products
    table has a
    supplier_id
    field that references the
    suppliers
    table. The
    suppliers
    table has a
    user_id
    field that references the user. The RLS policy fo the suppliers table is very simple:
    (uid() = user_id)
    . But I struggle to create the more complex policy required to protect the
    products
    based on that relationship.
    j
    • 2
    • 3
  • s

    Scott P

    01/12/2022, 3:24 PM
    RLS
  • j

    jason-lynx

    01/13/2022, 9:26 AM
    rls
  • c

    chipilov

    01/13/2022, 11:56 AM
    Does anyone know how what user is used to enable extensions from the dashboard?
    l
    • 2
    • 22
1...313233...52Latest