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

    jon.m

    10/01/2021, 11:26 PM
    Can anyone trouble shoot this sql for me?
    s
    • 2
    • 3
  • j

    jon.m

    10/01/2021, 11:26 PM
    Copy code
    delete from storage.objects where avatar is null (select objects.id, objects.name, avatar from storage.objects left join profiles on profiles.avatar like '%' || objects.name || '%' where bucket_id = 'avatars')
  • s

    silentworks

    10/02/2021, 1:24 AM
    Troubleshoot sql for delete
  • p

    Peanut

    10/02/2021, 4:23 AM
    Why are my SQL statements timing out for a newly created project?
  • p

    Peanut

    10/02/2021, 4:24 AM
    Connecting to the server seems to time out
  • p

    Peanut

    10/02/2021, 4:24 AM
    I tried restarting it
  • p

    Peanut

    10/02/2021, 4:25 AM
    Memory usage is also at 60%
  • p

    Peanut

    10/02/2021, 4:41 AM
    Could there be a load balancer / firewall / whatever that is preventing my queries? I have been trying to do some DB backup/restores and I fear it has triggered some security to block my access
  • h

    HorseShoe

    10/02/2021, 6:33 AM
    How to require modules in plv8
  • h

    HorseShoe

    10/02/2021, 6:34 AM
    is it possible?
  • m

    magicbyt3

    10/04/2021, 4:06 PM
    Hey, i am confused with pgplsql - I have this query:
    Copy code
    sql
    DROP FUNCTION random_action;
    CREATE OR REPLACE FUNCTION random_action()
      RETURNS TABLE (
        id bigint,
        name varchar,
        type_name varchar
      ) AS
    $func$
    BEGIN
      RETURN QUERY(
        SELECT actions.id, actions.name, action_type.name as type_name
        FROM actions
        LEFT JOIN action_type ON (action_type.id = actions.action_type_id)
        ORDER BY random() 
        LIMIT 1
      );
    END
    $func$
    LANGUAGE plpgsql;
    It is returning a random row as expected, however type_name is always null and I am wondering how I can query this foreign table column. Any help is appreciated. Thanks in advance.
  • s

    Scott P

    10/04/2021, 5:05 PM
    Assuming you have an
    action_type.id
    which matches your
    actions.action_type_id
    , try aliasing the tables:
    from actions a
    and
    left join action_type b
    Then reference them as
    ON (b.id = a.action_type_id)
    It shouldn't make a difference, but sometimes it can help.
  • s

    sudo killall windows

    10/04/2021, 10:34 PM
    In an RLS query how do you use the values that the user is trying to insert?
  • s

    sudo killall windows

    10/04/2021, 10:35 PM
    I basically want to do something like
    Copy code
    (1=blankvalueFromInsert)
  • s

    sudo killall windows

    10/04/2021, 10:47 PM
    can anyone help 😅
  • s

    Steve

    10/04/2021, 10:55 PM
    You can't do that with RLS. For that case you'd need a trigger or a check constraint(assuming you're trying to validate user input)
  • s

    sudo killall windows

    10/04/2021, 10:55 PM
    nooooo
  • s

    sudo killall windows

    10/04/2021, 10:56 PM
  • s

    sudo killall windows

    10/04/2021, 10:56 PM
    basically what I'm doing is checking user input (would be easier if i could eliminate this step), and making sure it matches something i have stored in a db
    s
    j
    s
    • 4
    • 50
  • s

    sudo killall windows

    10/04/2021, 10:57 PM
    Tldr; user sends discord id, i want to check that to make sure it is what i have in my db, and if not deny it
  • s

    sudo killall windows

    10/04/2021, 10:58 PM
    using this query to get the actual discord id
    Copy code
    sql
    SELECT
          raw_user_meta_data->>'provider_id'
        from
          auth.users
  • s

    sudo killall windows

    10/04/2021, 10:59 PM
    What's the easiest way to do this if not using RLS?
  • m

    magicbyt3

    10/05/2021, 12:51 PM
    yea it doesn't make a difference. I tried a lot of stuff found on stackoverflow however it seems to be a scientific highly complex task to query a table row and it's related rows in pgsql
    j
    • 2
    • 1
  • h

    Hal

    10/05/2021, 4:20 PM
    I see that we can put stored object id as a foreign key. But, storage has its own api, so what is it for?
  • j

    jason-lynx

    10/06/2021, 1:39 AM
    type name null
  • j

    jason-lynx

    10/06/2021, 4:15 AM
    for example, you might have user profile pics stored as objects, and in your users table you wanna have a foreign key to reference each object so that you know which user has which pic?
  • h

    Hal

    10/06/2021, 9:27 AM
    I thought so, but so far I can’t find any way other than to just store the name of the file and query it using .storage() after querying the users table beforehand. Not using objectid FK relationship
  • h

    Hal

    10/06/2021, 9:30 AM
    It would be nice to have the signedURL from a single query instead of running a second query just to get the signedURL of the avatar
  • j

    Jaeden

    10/07/2021, 8:18 AM
    Simple question. I have a boolean column in my table called
    public
    . I want to enable read access if the
    public
    column is set to
    true
    or if the
    author_id
    column matches the uid. This is what I have so far when I click on
    Edit
    in the policy for this specific table, but it doesn't seem to work. I'm new to SQL expressions and not sure if this is the way to do it.
    Copy code
    (
      (true = public)
      OR (uid() = author_id)
    )
  • j

    jason-lynx

    10/07/2021, 9:05 AM
    try
    (uid() = author_id OR public)
1...181920...52Latest