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

    Khan W

    08/02/2021, 4:47 PM
    Go to Settings -> Database -> Scroll to bottom and there's the connection string
  • k

    Khan W

    08/02/2021, 4:48 PM
    you'll need the password you made when you started the project too, as that's the password for your postgres instance
  • b

    babayaga

    08/02/2021, 4:53 PM
    Hello guys, does anybody know how to random query to users table or any table?
  • k

    Khan W

    08/02/2021, 6:28 PM
    Copy code
    sql
    select your_columns from your_table ORDER BY random()
    b
    b
    • 3
    • 7
  • b

    burggraf

    08/02/2021, 6:52 PM
    Random record selection
  • s

    spiderz

    08/02/2021, 8:08 PM
    How do I copy an entire Supabase database Schema to a new Schema. We are moving from development to QA phase and then eventually production. Is there a way to clone the entire schema without the data.
    s
    • 2
    • 2
  • v

    venca

    08/02/2021, 9:56 PM
    Is it possible to create sql function for adding files into storage? I would like to have check for table before inserting file so it would be best to do it in single query
  • r

    RobertS

    08/03/2021, 1:18 PM
    I might have found a bug. I have a trigger which I created before last weeks updates. It effectively connected two tables,
    articles
    and
    users
    in a m2m table called
    articles_users
    . The name of the trigger is
    on_article_created
    . When I try to drop the trigger using SQL:
    drop trigger on_article_created on public.articles;
    I get and error saying
    An error occurred with your deployment
    b
    • 2
    • 6
  • a

    Abnazhor

    08/04/2021, 3:06 PM
    Hello, is it possible to create a policy that validates what information is passed in a query? For example, doing
    SELECT * FROM Foo WHERE bar = 25
    , create a policy that depends on the value of bar. I've been searching for a while and I'm not sure if that is possible at all
    b
    l
    • 3
    • 3
  • b

    burggraf

    08/04/2021, 7:58 PM
    RLS - validating information from other tables
  • k

    kennethcassel

    08/04/2021, 9:25 PM
    Noob question. what would the matching SQL statement for this supabase query be?
    Copy code
    js
    const { data: courses, error } = await supabase
            .from('courses')
            .select(
              `*, 
            lessons (
              lesson_id, lesson_order)`
            )
            .eq('user_id', 5)
  • u

    user

    08/04/2021, 9:31 PM
    like you want the raw SQL for the Supabase method?
  • k

    kennethcassel

    08/04/2021, 9:31 PM
    yea
  • m

    Mihai Andrei

    08/04/2021, 9:32 PM
    Select * from courses inner join lessons on lessons.lesson_id = courses.lesson_id where courses.user_id = 5 But Im not really sure without seeing the columns in courses
  • u

    user

    08/04/2021, 9:32 PM
    yeah I would agree with the above
  • k

    kennethcassel

    08/04/2021, 9:46 PM
    Thanks yโ€™all ๐Ÿ™‚
  • d

    Deleted User

    08/05/2021, 12:01 PM
    Trying to create new roles to query against them with RLS, GRANT new_role to authenticator after granting "new_role" to authenticator how would we go to actually assign this "new_role" role to a specific user in auth.users instead of the current "authenticated" role, I tried update auth.users set role = 'new role' but it does not work with RLS when trying to access auth.role() = 'new role'
    s
    • 2
    • 7
  • s

    silentworks

    08/05/2021, 1:24 PM
    Adding new Postgres roles
  • l

    LeDragunov

    08/05/2021, 5:37 PM
    Hello, has anyone experienced issue with foreign keys?
    Error updating foreign key: there is no unique constraint matching given keys for referenced table "countries"
    even though all the values in the column are unique
  • s

    silentworks

    08/05/2021, 6:19 PM
    The error says there is an error updating foreign key, it's a bit hard to tell what is wrong without seeing the data
  • b

    bdlukaa

    08/05/2021, 7:30 PM
    probably because there is no column called
    countries
  • m

    mikebarkmin

    08/05/2021, 8:01 PM
    Hi. Can you create users on-the-fly without an email or anything and use theses in a policy for RLS? Example: A registered user created a survey. Participants (unregistered) take part in that survey. Participants will get a unique id, which will also be stored in a cookie. Participants should only be allowed to see their results
  • l

    LeDragunov

    08/05/2021, 11:36 PM
    @User @User this is the new table(vendor) columns
  • l

    LeDragunov

    08/05/2021, 11:37 PM
    and this is the countries table (supabase default table)
  • s

    Scott P

    08/05/2021, 11:42 PM
    I would make sure one of your columns on the countries table has the
    UNIQUE
    property set - whichever column you're trying to match against should have it set. It looks like it might be trying to perform a query against a table using a column which doesn't have UNIQUE set. That can lead to ambiguous results at best, but Postgres will usually just stop the query to prevent problems (e.g. data being overwritten incorrectly) in the case of an
    UPDATE
    query. Example: https://www.postgresqltutorial.com/postgresql-unique-constraint/
  • l

    LeDragunov

    08/06/2021, 12:13 AM
    oh thanksss, I thought only the values should be unique.
  • r

    rayyanmaq1

    08/06/2021, 3:01 AM
    Anyone how to crete rcp() i am having issue in return type
  • h

    hackerdocc

    08/06/2021, 12:02 PM
    gm everyone. Can someone help me avoid infinite recursion in RLS policies? I created an accounts table to associate auth.users with some public schema information (mainly the table customers), and I was using it together with auth.email() in my policies. But of course! When I define the policies for the accounts table itself, it results in infinite recursion. What should I do?
  • k

    Kosh

    08/07/2021, 1:53 PM
    Never thought (nested counting) this is possible until I tried it ๐Ÿ™ˆ
    Copy code
    .select(
              "*, following_user:follower(id, username, profile_picture, follower_count:friends.following(count)), "
              "follower_user:following(id, username, profile_picture, follower_count:friends.following(count))",
            )
    #motherofnesting
    b
    • 2
    • 26
  • b

    burggraf

    08/07/2021, 2:54 PM
    nested counting
12345...52Latest