https://supabase.com/ logo
Join Discord
Powered by
# help-and-questions
  • Slow database queries
    n

    Nico PM

    04/19/2023, 8:02 PM
    Hi folks! ๐Ÿ‘‹ We noticed a high latency when doing database queries. The times provided by
    explain analyze
    on the queries are what we'd expect (some tables have very few rows, execution time ~1ms) but the time it takes since we perform the query using the Supbase client to when the data is available is many orders of magnitude higher. Both our backend and Supabase projects are in the same region. We also noticed that the roundtrip is much faster when using a direct connection to the Postgres DB. Has anyone experienced this before? Are there any solutions to improve latency?
    g
    r
    s
    • 4
    • 22
  • !! Please help: Database egress with SQL function
    m

    mikel

    04/19/2023, 8:11 PM
    Hey, I have analytics data stored in JSONB. The size of the JSONB is 20kb for this example. Let's say I run an SQL function that updates just one key-value of the JSONB from total_view: 399 to total_view: 400. How much egress will that take from my database? Will it count as 20kb or just the differences (in this case, it's a few bytes, but let's say I make a change of around 10kb, so the new total size will be 30kb. How much egress will count as in this case?) Worth saying, I am calling this SQL function from Node using .rpc. Please help me! Thanks!
    g
    • 2
    • 14
  • Uploading IMG with python in storage
    i

    Ilgrand

    04/19/2023, 8:18 PM
    Someone of you knows how to upload an image in a bucket, the main problem is that the file extension is wrong, because in the bucket it appears as a .txt
    g
    j
    • 3
    • 2
  • Get users on client - update claim
    f

    fred kufner

    04/19/2023, 9:24 PM
    Hi there, new to supabase, testing to see if I can swap out auth0. I have magic link working for authentication in my vue app. I want to implement invite only for my app. I put the custom claims package in place and am able to access the claims from my app. Here is the flow I want: 1) Allow people to signup with magic link 2) Look for "approved" claim on authenticated user. If they have it allow them in. If not, tell them they are on waiting list 3) My app will have internal web page to see which users are awaiting approval. 4) Allow employee to click "approve" on users and update their claim accordingly. Not sure how to get list of auth.users from my app?
    g
    • 2
    • 2
  • Same trigger working on one table, but not another
    a

    ashman

    04/19/2023, 9:45 PM
    Hi, I have a trigger to create a slug (based on name column) whenever a row is created or modified which works great on table A, but I recently decided to use those same functions to create a trigger on a different table B which also has a name column, but it is not working. Happy to share any of the details if needed, but I'm wondering if anyone knows a reason for the same trigger to work on one table but not another? I have tried disabling RLS and recreating the trigger on table B, but that did not make a difference. I don't see any errors in the logs either, and I have a different "updated_at" trigger on table B which is working fine, so no issues having triggers in general, just this one...
    g
    • 2
    • 2
  • JSON SQL queries return NULL
    s

    snelson

    04/19/2023, 10:16 PM
    I have a bunch of stuff stored in JSON type columns. For some reason, my SQL queries all come back as NULL. I can confirm that the query syntax is correct so it must have to do either a) with my data (more likely), or b) there's a bug in the SQL editor (less likely). But wanted to see if there are any known issues with JSON extraction before going down a rabbit hole here.
    g
    • 2
    • 9
  • Deno mongo db driver, fails to run with generic error once deployed
    w

    wax911

    04/19/2023, 10:40 PM
    Using https://github.com/denodrivers/mongo I get an en Error: MongoError: "Invalid response header" at WireProtocol.receive (https://deno.land/x/mongo@v0.31.2/src/protocol/protocol.ts:77:38) I would like to understand why this is happening on edge functions
  • Mockup auth.users table in local dev
    j

    Joyboy

    04/19/2023, 10:51 PM
    Hi! I'm working on a SQL function to fill the auth.users table with a given number of rows for local development. I manage to complete the creation function but I didn't find a way to handle password hash in
    encrypted_password
    column. I tried to manually register a user with, let's say
    12345678
    and hardcode the hash in all rows but as expected, it didn't work. I was hoping to get a better understanding of the way supabase encrypts passwords and maybe find a way to mokcup a large number of users and still be able to login as any of them. However, this is my scropt in case it helps:
    Copy code
    SQL
    BEGIN;
    
    WITH user_values AS (
      SELECT
        uuid_generate_v4() AS id,
        uuid_generate_v4() AS instance_id,
        'authenticated' AS aud,
        'authenticated' AS role,
        (ROW_NUMBER() OVER ()) || '@gmail.com' AS email,
        '$2a$10$nc8ek4I97q1rDN6w3jKj8uUuKGF1fMlfKaD1GNPtYDwhW6IVzA39i' AS encrypted_password,
        now() AS email_confirmed_at,
        NULL::timestamp AS invited_at,
        '' AS confirmation_token,
        NULL::timestamp AS confirmation_sent_at,
        '' AS recovery_token,
        NULL::timestamp AS recovery_sent_at,
        '' AS email_change_token_new,
        '' AS email_change,
        NULL::timestamp AS email_change_sent_at,
        NULL::timestamp AS last_sign_in_at,
        '{"provider":"email","providers":["email"]}'::jsonb AS raw_app_meta_data,
        '{}'::jsonb AS raw_user_meta_data,
        0::boolean AS is_super_admin,
        '2022-10-04 03:41:27.391146+00'::timestamp AS created_at,
        '2022-10-04 03:41:27.391146+00'::timestamp AS updated_at,
        NULL AS phone,
        NULL::timestamp AS phone_confirmed_at,
        '' AS phone_change,
        '' AS phone_change_token,
        NULL::timestamp AS phone_change_sent_at,
        '' AS email_change_token_current,
        0 AS email_change_confirm_status,
        NULL::timestamp AS banned_until,
        '' AS reauthentication_token,
        NULL::timestamp AS reauthentication_sent_at
      FROM generate_series(1, 100)
    ),
    ....
    s
    • 2
    • 6
  • Create trigger to take confirmationToken from inviting user, to the public database profile table
    s

    SunTzu

    04/19/2023, 11:40 PM
    Hi, I've got a process where the user is invited to the system. I want to make it so they accept the invite, reach a page and complete additional information with their profile. In order to secure this, I want to check the confirmationToken and email. (Which i pass as query parameters in the confirmationURL in the email). So when the page loads, I do a supabase call to confirm those two match in the database in order to allow them to complete the information. How can i create a database trigger to take that confirmationToken into the public profile database. Or is there a better way?
    • 1
    • 1
  • I'm getting no Postgres user name specified and other errors randomly
    a

    Anshuman

    04/20/2023, 1:14 AM
    As shown in the image, I get these errors but seldom and it's the first time I'm seeing these. My queries work fine 98% of the time but timeout when these error happen. The logs aren't so helpful either.

    https://cdn.discordapp.com/attachments/1098416390618222733/1098416391394185296/image.pngโ–พ

    g
    • 2
    • 4
  • Combine or() with and filter
    g

    garyaustin

    04/20/2023, 2:00 AM
    You did not close ) your last and.
    s
    • 2
    • 3
  • What is the preferred storage location for session auth tokens? LocalStorage or HttpOnly cookies?
    c

    ceN

    04/20/2023, 1:44 AM
    I'm building a Chrome extension and would like to preserve the user session so they don't have to keep logging in if they've closed the browser. Should I store the session in a cookie or localStorage?
    j
    • 2
    • 2
  • error converting time string to_number
    d

    DaveNash

    04/20/2023, 1:49 AM
    I'm using "to_number(departure_time, 'HH24:MI:SS')" to get a number from a time provided as a string in that format (e.g., "05:20:00"), which should work according to docs (linked below), but I'm getting this error: "Failed to run sql query: cannot use "S" and "PL"/"MI"/"SG"/"PR" together" Anyone see what I'm doing wrong? https://www.postgresql.org/docs/8.2/functions-formatting.html
  • Latest docker images
    v

    ven

    04/20/2023, 2:07 AM
    Does updating the supabase cli (currently on 1.50.9) automatically update the local docker images or do i need to go to docker hub and pull individual images myself? thank you
    s
    • 2
    • 2
  • Exploring Cron Table Security and Schema Reference Clarifications
    a

    Aviation

    04/20/2023, 3:19 AM
    Hey there! I noticed that the cron schema isn't protected by default, and I'm curious if there's a particular technical reason behind this decision. It struck me as a potential security risk, so I thought I'd check in with you. Additionally, I observed that in the cron schema, the job_run_details.jobid column seems like it should reference the job.id column, but there's no reference requirement in place. Is this intentional or just a small oversight? I'd love to learn more about the rationale behind it before making any adjustments. Thanks in advance for your insight!
    g
    • 2
    • 1
  • Where are CREATE TYPE stored?
    c

    Corrupted

    04/20/2023, 5:16 AM
    I created a snippet that helps me recreate a table, in that snippet was a query to create a type for one of my columns. When I went to run the snippet again, I got an error that the TYPE already exists. Where are these custom defined TYPES stored?
    g
    • 2
    • 2
  • [nextjs13/app-dir] Does getSession() hit the database every time?
    m

    metafoo

    04/20/2023, 5:33 AM
    Or does it take advantage of nextjs' request deduplication, in case of calling it multiple times while rendering various server-components?
    j
    • 2
    • 2
  • [nextjs13/app-dir] What's your favorite way to implement protected routes?
    m

    metafoo

    04/20/2023, 5:46 AM
    Currently discussing various strategies with my colleges... Any best practises? ๐Ÿ™‚
  • Foreign Key Constraint Key is not present in table "users"
    f

    Fisher

    04/20/2023, 7:37 AM
    Hey guys, learning more and more with backend development but I'm having an issue with foreign key constraints. I have a Join table called split_members that has a foreign key that references the public.users.wallet_address key. Sometimes the user hasn't been created yet, so I created a function and a trigger to check if the user already exists and then inserts the wallet_address prior to inserting my "split_member". I keep getting
    Copy code
    code
    : 
    "23503"
    details
    : 
    "Key is not present in table \"users\"."
    hint
    : 
    null
    message
    : 
    "insert or update on table \"split_members\" violates foreign key constraint \"split_members_user_recipient_address_fkey\""
    Ive been banging my head against the wall for hours now lol. Anyone have any words of advice?
  • Launch week 7 giveaway question
    m

    MaxTechnics

    04/20/2023, 7:53 AM
    I got a message from supabase telling me i won a shirt, and to dm the supabase twitter account. I'm not sure if i'm either doing it wrong, or believed a fake tweet. But haven't gotten a response for a few days now. Is this normal? (and should i just wait another while) Or not? Thanks in advance!
    s
    • 2
    • 1
  • ./$types"' has no exported member named 'LayoutServerLoad'
    h

    Hermanus147

    04/20/2023, 8:52 AM
    Hi, in the Sveltekit +layout.server.ts I get the follow error: '"./$types"' has no exported member named 'LayoutServerLoad'. Did you mean 'LayoutServerData'? My Supabase devDependencies: "@supabase/auth-helpers-sveltekit": "^0.9.4", "@supabase/supabase-js": "^2.21.0", +layout.server.ts file: import type { LayoutServerLoad } from './$types'; export const load: LayoutServerLoad = async ({ locals: { getSession } }) => { return { session: getSession() }; }; Any help will be appreciated thanks.
    j
    s
    • 3
    • 5
  • Can I do CSV Import via Supabase Dashboard?
    m

    Marcio

    04/20/2023, 8:57 AM
    Hello, I'm currently working with a Supabase database, right now I'm adding the data manually one by one, but I'd like to import a large amount of data at once from a CSV file directly into my database. Is there a built-in feature or a recommended way to do this through the Supabase web dashboard? Any help or suggestions would be greatly appreciated. Thank you!
    v
    • 2
    • 1
  • Edge function works locally, but fails bundling
    t

    tobowers | Crypto Colosseum

    04/20/2023, 9:47 AM
    I have an edge function that imports this package:
    https://esm.sh/ethers@5.7.2
    and the function runs perfectly fine locally, but when I go to deploy I'm getting:
    Copy code
    Error: Error bundling function: exit status 1
    file:///src/import_map.json
    file:///src/index.ts
    file:///_shared/cors.ts
    file:///_shared/serviceClient.ts
    error: Uncaught (in promise) Error: Module not found "https://esm.sh/v116/bn.js@5.2.1/index.d.ts".
          const ret = new Error(getStringFromWasm0(arg0, arg1));
                      ^
        at __wbg_new_8d2af00bc1e329ee (https://deno.land/x/eszip@v0.30.0/eszip_wasm.generated.js:312:19)
        at <anonymous> (https://deno.land/x/eszip@v0.30.0/eszip_wasm_bg.wasm:1:79439)
        at <anonymous> (https://deno.land/x/eszip@v0.30.0/eszip_wasm_bg.wasm:1:1388039)
        at <anonymous> (https://deno.land/x/eszip@v0.30.0/eszip_wasm_bg.wasm:1:1862894)
        at __wbg_adapter_18 (https://deno.land/x/eszip@v0.30.0/eszip_wasm.generated.js:146:6)
        at real (https://deno.land/x/eszip@v0.30.0/eszip_wasm.generated.js:130:14)
    • 1
    • 8
  • REST API returns "created" during upsert, even when the record was updated
    v

    Vadorequest

    04/20/2023, 11:27 AM
    The
    statusText
    is always "Created" even when the operation was an update. I guess this is related to the pgREST plugin, and not directly to Supabase, but I wanted to know if this behavior is expected.

    https://cdn.discordapp.com/attachments/1098570667319894118/1098570667634462882/image.pngโ–พ

    r
    • 2
    • 8
  • Checking if user is admin when selecting profiles results in infinite recursion
    s

    SmadreThorkild

    04/20/2023, 11:33 AM
    Hello everyone. The attached image describes my schema, where
    profiles
    is a foreign table to
    auth.users
    . I use the
    profiles
    .
    is_admin
    column to determine if the authenticated user is admin or a regular user. I'm trying to create an RLS policy where regular users can only select their own profiles (
    id = auth.uid()
    ) but where admins can select all profiles. This currently results in infinite recursion, because I'm selecting
    is_admin
    from the same table in a subquery, resulting in recursion. Is there any way to either bypass RLS or can I manage user roles in other ways using Supabase/Postgres? Any help is highly appreciated ๐Ÿ™‚ The policy I've tried looks like this:
    Copy code
    id = auth.uid()
      OR EXISTS (
        SELECT
          is_admin
        FROM
          profiles AS p
        WHERE
          p.id = auth.uid()
          AND p.is_admin = true
      )

    https://cdn.discordapp.com/attachments/1098572046335758407/1098572046763573368/Skrmbillede_2023-04-20_kl._13.23.23.pngโ–พ

    g
    s
    • 3
    • 6
  • Do we need some LOGFLARE_API_KEY for local logging?
    j

    jarnold

    04/20/2023, 12:03 PM
    +1 https://discord.com/channels/839993398554656828/1095068497740046517 Gettin the following when opening up the logging panel { "code": 500, "message": "LOGFLARE_API_KEY env variables are not set" }
    g
    • 2
    • 2
  • Daily backups: indexes and programmable access
    h

    Hemingway

    04/20/2023, 1:56 PM
    Hi folks, After some research, it seems that the daily backup files does not contain any indexes created. I wonder if that's by design? Does it mean when restoring, all indexes will be lost? Also, is there a way to programmablly download the most recent daily backups? It seems like a waste of compute if I run separate pgdump for a off-site backup if the backup is already done. Thanks!
  • supabase helm problem
    r

    Roman Vladimirov

    04/20/2023, 2:04 PM
    Hello everyone, I used this Quickstart guide https://github.com/supabase-community/supabase-kubernetes/blob/main/charts/supabase/README.md and encountered an issue in microk8s. Everything starts successfully, but it's impossible to open the standard project - it's stuck on an infinite loading screen. Please help

    https://cdn.discordapp.com/attachments/1098610108478533652/1098610108633714708/Screenshot_4.pngโ–พ

    https://cdn.discordapp.com/attachments/1098610108478533652/1098610108944097420/Screenshot_3.pngโ–พ

  • Trigger to update user doesn't seem to be working
    s

    SunTzu

    04/20/2023, 2:04 PM
    So I wrote this little trigger
    Copy code
    create or replace function public.handle_update_user() 
    returns trigger 
    language plpgsql 
    security definer set search_path = public
    as $$
    begin
    update public.profiles 
    set email = new.email,
    full_name = new.raw_user_meta_data->>'full_name',
    avatar_url = new.raw_user_meta_data->>'avatar_url',
    username = new.raw_user_meta_data->>'username'
    where id = new.id;
      return new;
    end;
    $$;
    
    create trigger on_auth_user_updated
    after update of email on auth.users
      for each row execute procedure public.handle_update_user();
    When a user does an update to their account, I was hoping to update the public.profiles table with the additional data they updated. (full_name, username etc). However it doesnt seem to be running. Is there anything I should change with this?
    s
    • 2
    • 2
  • Bulk upload in Supabase
    k

    kuna

    04/20/2023, 2:41 PM
    Iโ€™m trying to do bulk upload. I loop over a fileList in an async function with forโ€ฆof then upload each file in the list with await. How do I wait for the loop to finish then update my React state?
1...186187188...230Latest