https://supabase.com/ logo
Join Discord
Powered by
# help-and-questions
  • Parse numbers from text.
    v

    VuNguyen

    01/26/2023, 4:21 PM
    I wanna parse numbers from text, I'm using following command but it doesn't seem to work.
    Copy code
    sql
    select (COALESCE((regexp_matches(name, '^\D*(\d+(?:\.\d+)?)'))[1]::numeric, 0)), name from kaguya_chapters where slug = 'cmk-2367229' limit 1
    it returns
    Copy code
    Failed to run sql query: set-returning functions are not allowed in COALESCE
    Expected result Chapter 124.5: Omake Volume 14 -> 124.5
    • 1
    • 1
  • Realtime joints
    a

    A-PRYME

    01/26/2023, 4:35 PM
    Given that real-time data fetching is limited only to a single table, I'm just wondering how do you handle scenarios where you REALLY need joints, i.e you want both a Post and its Comments as a stream, how do you get that?
    g
    • 2
    • 1
  • signing JWTs from third-party auth (Stytch) to use with Supabase
    d

    dogedogego

    01/26/2023, 4:39 PM
    hey all, I’m trying to figure out the best way to sign JWTs we get from Stytch from what I can tell we have to have a middleware/intermediary server to sign then as it’s the Supabase secret which can’t be exposed should edge functions be used or optimized compute? is optimized compute just a standard “always on” server deployed in a similar manner?
    g
    • 2
    • 13
  • How would you: supabase auth + metamask ?
    s

    streamerd

    01/26/2023, 4:52 PM
    Hello everyone, currently running through a case here. We have an app, where users can either use an email login or a wallet login. If they connected with wallet, they can create a community (for a place) with orbis protocol. So far, so good. However, data about those places (and their community_id ) is stored on supabase. My issue is, when user initiates a web3 community for a place, that community id should be sent as an update to that place they're creating the community for. Problem is, when they connect with wallet, they don't necessarily have an auth session, hence they cannot make updates (RLS). There might be many workarounds, but I wonder how would you deal with this? Is that even possible with free membership /without edge functions?
  • JS: syntax for OR/match at least one filter
    d

    Domcario

    01/26/2023, 5:00 PM
    my table is called
    company
    with columns
    owner
    (uuid) and
    members
    (uuid array). i have the currently signed in user's uuid saved as an object called
    user_id
    i'd like to query for all rows in
    company
    where user.id is equal to the row's owner value OR user.id is one of the uuids in the array for
    members
    currently trying this with a string literal, following along docs here https://supabase.com/docs/reference/javascript/or
    Copy code
    js
    const { data, error } = await supabase
      .from('company')
      .select()
      .or(`owner.eq.${user_id},members.cs.{${user_id}}`)
    g
    • 2
    • 1
  • How to implement loading state with signInWithOAuth?
    l

    Lukas V

    01/26/2023, 5:09 PM
    Hello, I have implemented
    signInWithOAuth
    logic into my login modal. Everything works, however, I currently have very bad user experience due to my loading state not being set properly. Here is my code:
    Copy code
    const handleOAuthSignIn = async (provider: Provider) => {
        toast.loading('Signing you in with ' + provider + '...');
        const { error } = await supabaseClient.auth.signInWithOAuth({
          provider
          // options: { redirectTo: getURL() }
        });
        if (!error) toast.dismiss();
        if (error) {
          toast.error(error.message);
          toast.dismiss();
        }
      };
    Please watch the screen recording, as you can see
    toaster
    component is being activated only for split second before it dissappears. This especially confusing when the internet might not be as fast, i was testing this with my friend, once he pressed the sing in with apple button, ui was unresponsive for about 5-7 seconds, even I thought at that time that it's simply not working, but it was just loading slowly. How do I overcome this issue?
    y
    • 2
    • 3
  • How do you update a field in a table with javascript or php?
    a

    AntDX316

    01/26/2023, 5:14 PM
    How do you update a field in a table with javascript or php? Do I need the database URL?
    i
    • 2
    • 1
  • Joins on foreign key working in SQL but not in PostgREST
    j

    jaypinho

    01/26/2023, 5:15 PM
    I have the following query that works perfectly when run in Supabase's SQL query editor:
    Copy code
    SELECT daily_company_counts.*, companies.company
    FROM daily_company_counts
    join companies on companies.id = daily_company_counts.company_id
    WHERE normalized_date = '2023-01-22'
    This returns 906 rows. However, no matter how I structure my PostgREST query, I cannot get it to work. Either: a) I do a join without using
    inner
    , which results in me receiving those same 906 rows but 781 of them come back with no associated resource in the
    companies
    table:
    Copy code
    https://abhxwgvatqovevkjxlyy.supabase.co/rest/v1/daily_company_counts?apikey=[KEY]&select=*,companies!daily_company_counts_company_id_fkey(company)&normalized_date=eq.2023-01-22
    OR b) I do a join using
    inner
    and get back only the 125 rows:
    Copy code
    https://abhxwgvatqovevkjxlyy.supabase.co/rest/v1/daily_company_counts?apikey=[KEY]&select=*,companies!daily_company_counts_company_id_fkey!inner(company)&normalized_date=eq.2023-01-22
    Am I missing something here?
    g
    • 2
    • 8
  • psql can't connect
    e

    Eric Hanson

    01/26/2023, 5:27 PM
    Hello! Loving me some Supabase, but I am unable to connect to the database using
    psql
    . I'm just pasting in the provided prompt in the Database Settings section if the UI and using the password I set but it is not working:
    Copy code
    eric@play:~/dev$ psql -h db.nalqklftpdqglmwfbuoy.supabase.co -p 5432 -d postgres -U postgres
    Password for user postgres: 
    psql: error: connection to server at "db.nalqklftpdqglmwfbuoy.supabase.co" (18.231.187.145), port 5432 failed: FATAL:  password authentication failed for user "postgres"
    connection to server at "db.nalqklftpdqglmwfbuoy.supabase.co" (18.231.187.145), port 5432 failed: FATAL:  password authentication failed for user "postgres"
    Two problems, first the login didn't work with the above message so I thought maybe I have the wrong password, so I changed it, and then the port just closed and I could no longer connect:
    Copy code
    eric@play:~/dev/aquameta$ psql -h db.nalqklftpdqglmwfbuoy.supabase.co -p 5432 -d postgres -U postgres
    psql: error: connection to server at "db.nalqklftpdqglmwfbuoy.supabase.co" (18.228.119.85), port 5432 failed: Connection refused
        Is the server running on that host and accepting TCP/IP connections?
    However I worked around this, I paused my project and then restarted, and that fixed the issue with the port being closed. But still, password wont' work. I also tried doing an
    ALTER ROLE postgres LOGIN
    but that also didn't fix it. Any ideas? Thanks!
    g
    • 2
    • 16
  • when I reload simulator I sometimes I get error but sometimes it works and pulls the data.
    t

    tarkan

    01/26/2023, 5:39 PM
    this is error: {"code": "42883", "details": null, "hint": "No operator matches the given name and argument types. You might need to add explicit type casts.", "message": "operator does not exist: uuid = text"} *isUserUUID always returns true. * id in profiles table is uuid. this is my code: if (session !== null && session.user.id !== null) { const regexExp = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/gi; const isUserIdUUID = regexExp.test(session.user.id); console.log("isUserIdUUID", isUserIdUUID) const profile = await supabase.from("profiles").select("*").eq("id", session.user.id).single() if (profile.data !== null) setProfile(profile.data) else if (profile.error !== null) console.log('this--------', profile.error) }
  • Authenticating AWS Lambda endpoint with Supabase user authentication
    r

    Raphael_

    01/26/2023, 5:42 PM
    Hello, I am working on a Next.js project that is using Supabase for authentication. I am trying to authenticate an AWS Lambda endpoint so that only signed-in users who have subscribed to a specific service can access it. Can anyone provide guidance on how to achieve this using Supabase and AWS Lambda? Thank you in advance for your help
    a
    • 2
    • 1
  • Should I close connections manually?
    u

    user8923

    01/26/2023, 5:59 PM
    I'm using serverless functions at Netlify and within them I'm querying a Supabase DB using the postgres.js client, which has its own internal pool (I think). I use the 6543 port, so I assume connections are pooled by the Supa pgBouncer server too. I'm not sure whether I should close the connections manually within the function code, or if they are closed automatically when the function is done running. Additionally, since the connections are taken from a pool, I shouldn't need to close them since open connections will be reused by the next caller? All of this together is a bit confusing to me. Any best practices out there? Thank you!
    c
    • 2
    • 3
  • RLS relation SELECT and UPDATE
    p

    pckimlong

    01/26/2023, 6:07 PM
    I wonder Do RLS of insert and update are relating to each other. I ask because in flutter app when I perform insert with select on table which has restricted on update it returned "not found", but if I change table's RLS on update to unrestricted, the insert with select in flutter app will return record for me
    g
    • 2
    • 2
  • Billing usage showing as Zero
    d

    DanMossa

    01/26/2023, 7:18 PM
    Hello! My Usage under Billing is showing everything at
    0
    . I'm wondering if other people are having the same issue?
    g
    • 2
    • 3
  • "Missing FROM-clause entry for table new" when creating policy
    v

    Vik

    01/26/2023, 7:23 PM
    Hey there, I'm trying to create a policy on my followers table so only inserts where the user_id's profile is not private and the user is authenticated. This is what I currently have:
    Copy code
    CREATE POLICY followers_insert_policy ON followers
    FOR INSERT
    WITH CHECK (NOT EXISTS (SELECT 1 FROM profiles WHERE profiles.id = NEW.user_id AND profiles.private = TRUE)
    AND current_user = 'authenticated_role');
    This is the error I get:
    Copy code
    Failed to run sql query: missing FROM-clause entry for table "new"
    g
    • 2
    • 2
  • Image transformation api returns 400 bad request
    r

    ryanT

    01/26/2023, 7:34 PM
    When I try to use the image transformation api I get 400 bad request. Here's my supabase-image-loader.js:
    Copy code
    export default function supabaseLoader({ src, width, height, quality }) {
      return `${process.env.NEXT_PUBLIC_SUPABASE_URL}/storage/v1/render/image/public/${src}?width=${width}&height=${
        height
      }&quality=${quality || 75}`
    }
    Heres my next.config.js
    Copy code
    /** @type {import('next').NextConfig} */
    const nextConfig = {
      reactStrictMode: true,
      swcMinify: true,
      eslint: {
        ignoreDuringBuilds: true,
      },
      images: {
        loader: 'custom',
        loaderFile: './scripts/supabase-image-loader.js',
        remotePatterns: [
          {
            protocol: 'http',
            hostname: 'localhost',
            port: '54321',
            pathname: '/storage/v1/**',
          },
          {
            protocol: 'https',
            hostname: process.env.NEXT_PUBLIC_SUPABASE_URL,
            port: '',
            pathname: '/storage/v1/**',
          },
        ],
      }
    }
    
    module.exports = nextConfig
    GET http://localhost:54321/storage/v1/render/image/public/bucket-name/customer_banner.png?width=1920&height=undefined&quality=75 400 (Bad Request) I also notice that the width and height in the get request are not what I've entered:
    Copy code
    <Image
              src={'bucket-name/customer_banner.png'}
              priority={true}
              alt="banner-image"
              width={1600}
              height={1600}
            />
    I've tried this on my local development supabase instance as well as my hosted one on supabase.com. Both result in 400s. I've also tried without the supabase-image-loader.js via:
    Copy code
    const bannerUrl = supabase.storage.from('bucket-name').getPublicUrl('customer_banner.png', {
        transform: {
          width: 1600,
          height: 1600,
        },
      });
    Same thing happens. Any ideas here?
    l
    g
    • 3
    • 51
  • Is it possible to use Supabase Realtime without receiving data? Essentially as a listener?
    v

    Vik

    01/26/2023, 8:25 PM
    I have a couple questions regarding how Supabase Realtime work behind the scenes. If, for example, I was listening to all inserts on a table where an ID field matched my logged in user is it possible to just listen for those changes and not send data back? The reason why I ask is because I use React Query for my state and the best I can do is intervals to refetch. My goal is to setup Supabase Realtime to listen to those changes and then call refetches using React Query to keep my application UI up to date.
    c
    • 2
    • 7
  • supabase-image-loader width and height are incorrect.
    r

    ryanT

    01/26/2023, 9:07 PM
    Using the following code I get 1920 for width and height undefined on the get request for the image. Whats going on here? Why is height undefined even though I've set it to 1600, why is width a different value than what I passed (1600)? The size of the image is 1600x1600x btw.
    Copy code
    export default function supabaseLoader({ src, width, height, quality }) {
      return `${process.env.NEXT_PUBLIC_SUPABASE_URL}/storage/v1/render/image/public/${src}?width=${width}&height=${height}&quality=${quality || 75}`
    }
    Copy code
    <Image
              src={'customer-assets/folder-name/customer_banner.png'}
              priority={true}
              alt="banner-image"
              width={1600}
              height={1600}
            />
    Copy code
    http://localhost:54321/storage/v1/render/image/public/customer-assets/folder-name/customer_banner.png?width=1920&height=undefined&quality=75
    g
    • 2
    • 12
  • Can we generate TS types from pg_jsonschema?
    c

    cohlar

    01/26/2023, 9:19 PM
    Can we somehow generate TypeScript types from JSON schemas defined with pg_jsonschema? At the moment when I generate types with the supabase cli,
    jsonb
    columns are typed as
    Json
    even when constrained by a json schema.
    o
    v
    • 3
    • 3
  • Custom Identity formula
    j

    jj_sessa

    01/26/2023, 9:54 PM
    Im interested in creating a custom identity formula, or seeding the identity from a custom number, example would be yy-1000 as the first seed and resets yearly. or just having new tables begin seeing at 1000. Is this possible under the default value formula section?
    g
    • 2
    • 1
  • Session is always null
    f

    fast

    01/26/2023, 10:38 PM
    As the title already says, my sessions are always null. I am using React + NextJS Login function:
    Copy code
    await supabase.auth.signInWithOAuth({
      provider: 'google',
      options: {
        redirectTo: REDIRECT_URL
      }
    })
    After a successful login the user gets redirected to the correct location but trying to get the session returns null
    Copy code
    React.useEffect(() => {
        (async () => {
          // Returns null
          const session = await supabase.auth.getSession();
          if(session.error && !session.data.session) {
            throw new Error("No session");
          }
    
          // Make API calls
        })()
      });
    Lmk if you need more information
    d
    • 2
    • 2
  • Missing JSON data type in storage UI?
    a

    andrewluo

    01/26/2023, 10:55 PM
    Maybe I am missing something here, but it seems for me the JSON data type is not available when creating columns anymore. When I looked at an old column with that type, it is just blank. Images attached. Any help appreciated!
    g
    j
    • 3
    • 6
  • How do I check if the user is logged in?
    b

    Basanites

    01/26/2023, 11:17 PM
    I made this function,
    Copy code
    async function getUser() {
        const user = await supabase.auth.getUser()
    
        if(user != null) return user;
        return null;
    }
    but I still can't check whether or not the user is logged in. Regardless of whether or not the user is logged in, I still see "Log Out" rendered in the navbar.
    Copy code
    export default function Navbar() {
      let user = getUser()
      if(user != null) { //This would return a version of my site's navigation bar with a "Log Out" button.
        return(
          ...
        )
      }
    }
    ^ That was a snippet from my navigation bar code. I'm trying to only render an tag to log out if the user is signed in.
    g
    y
    +2
    • 5
    • 28
  • sign in with google - "couldn't sign you in"
    d

    Domcario

    01/26/2023, 11:54 PM
    Getting spammed with this while building out new user flows. this is only affecting my and other user's @gmail.com accounts. if it's from my google workspace account (so it has a custom domain) it's fine. i'll be starting the sign in flow from localhost:3000 sign in with google goes to accounts.google.com sign in with a @gmail.com to reproduce this i've tried deleting my account from supabase's authentication tab several times (to recreate signing in as a new user for the first time with google), and this persists so it's probably not related?
  • Do any joins exist other than !inner and !outer?
    e

    elliott

    01/27/2023, 1:18 AM
    Struggling to find documentation around this. If I wanted to perform for example a right outer join, is that supported natively in the client?
    g
    • 2
    • 2
  • Can I filter out responses with empty lists?
    e

    elliott

    01/27/2023, 1:51 AM
    Here are two columns being returned from a supabase sql query: If I wanted to filter out this query so that responses where "messages_received" being an empty list were not accepted, can I pull that off from the native client?
  • Updating data with client on Cloudflare Worker
    r

    royboy789

    01/27/2023, 2:43 AM
    Hello! Thank you in advance if you have any knowledge. I"m trying to set up a Cloudflare Worker to run as my API between app and Supabase. All is working well, even got AUTH working well with cookies. I can GET / Select data no problem using the client
    client.from().select()
    but when it comes to updating
    client.from().update().select()
    it does not want to work. I have done everything i could to test, including copying the code directly into my app, where it works. Is this a client side / server side issue? Anyone have any experience with workarounds? I saw the Egghead course using KV store, not there yet, but didn't seemed like most of that was fetching/GET data, but not updating.
    g
    • 2
    • 25
  • Why use Supabase Storage over S3?
    k

    Ken

    01/27/2023, 3:46 AM
    Hey Everyone, I am considering using Supabase storage but I have some reservations. 1) I already have a ton of files in S3.. why would I start storing my files somewhere else? are Supabase buckets better than S3 buckets? Can I access the S3 bucket that Supabase targets directly? Or do I always have to go through Supabase?
    g
    • 2
    • 1
  • Is it good practice to unsubscribe from realtime in a useEffect?
    v

    Vik

    01/27/2023, 4:06 AM
    Pretty much what the title says, should I be returning unsubscribe in my useEffects? If I do, will the next change in the database still be sent? Trying to understand realtime and it's performance in an application.
  • I have a problem with RLS. Result Comes Empty with RLS
    y

    YokoWasis

    01/27/2023, 6:06 AM
    I would like to allow some specific signed-in users to select all data. I tried this
    Copy code
    (auth.email() IN ( SELECT ca_admin.email
       FROM ca_admin))
    ca_admin table :
    Copy code
    id | email
    ---|---------------------
    1  | yokowasis@gmail.com
    I auth using yokowasis@gmail.com, but when I try select the table, the results come empty.
    c
    o
    • 3
    • 4
1...110111112...230Latest