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

    kawallis

    10/27/2021, 3:44 AM
    does anyone know how to add a count column to a table that returns the count of related tables rows
    h
    w
    • 3
    • 3
  • y

    yurix

    10/27/2021, 9:55 AM
    Does anyone know what is the correct way to migrate to production databases?
    c
    s
    • 3
    • 7
  • c

    chipilov

    10/27/2021, 1:26 PM
    Database Migration
  • h

    HarryET

    10/27/2021, 1:26 PM
    Count Column
  • s

    stibbs

    10/28/2021, 10:57 PM
    I'm struggling with a plpgsql function to create/remove 'tags'. Hoping someone can point me in the right direction.
    j
    • 2
    • 6
  • h

    Helixen89

    10/29/2021, 1:18 AM
    I'm trying to upload a CSV (UTF-8) file, and I'm being met with this error. Any ideas? Even tried with a sample CSV i made from scratch, still not working.
  • d

    dreinon

    10/29/2021, 1:55 AM
    What separators are you using?
  • d

    dreinon

    10/29/2021, 1:55 AM
    And do you have headers in the csv (column names)?
  • h

    Helixen89

    10/29/2021, 2:00 AM
    , yes, with no special characters
  • d

    dreinon

    10/29/2021, 2:01 AM
    That's odd 😕
  • h

    Helixen89

    10/29/2021, 2:03 AM
    yeah, just imported through tableplus, so I'm ok but not sure what the issue is @ supabase
  • d

    dreinon

    10/29/2021, 2:03 AM
    Right
  • d

    dreinon

    10/29/2021, 2:04 AM
    What I used to import csv was drag and dropping the file
  • h

    Helixen89

    10/29/2021, 2:04 AM
    I tried that too, but Chrome just thought I was trying to open the file in the browser 🤷‍♂️
  • h

    Helixen89

    10/29/2021, 2:04 AM
    might be a browser issue now that I mention that
  • h

    Helixen89

    10/29/2021, 2:05 AM
    no console errors
  • h

    Helixen89

    10/29/2021, 2:11 AM
    same issue in firefox. oh well, will contact support and let them know. fortunately only need to do this once.
  • d

    dreinon

    10/29/2021, 2:17 AM
    Okay
  • d

    dreinon

    10/29/2021, 2:17 AM
    Good luck man!
  • s

    stibbs

    10/29/2021, 3:15 AM
    Setting up full text search https://supabase.io/docs/guides/database/full-text-search I'd like to create an index (refer Creating Indexes > Searchable columns) but I need to include data from another table Specifically: Full text search will be against my
    jobs
    table (this is where the index should go), and a
    jobs_tags
    table which is a mapping table containing all tags for each job. Should I add tags into the
    fts
    column in the jobs table? I don't think that would get the benefit of the auto updating index?
  • g

    garyaustin

    10/29/2021, 4:13 AM
    I moved from Firebase because of search/filter issues, one was ability to search wine titles for partial input. I thought full text search was the answer. It seems for short titles, words it is not that easy (it is more for descriptions, paragraphs). See this https://github.com/supabase/supabase/discussions/3542 for the main issue I also find myself in. Full text does not match until you have close to whole words and mainly what is in the dictionary you pick. The ts_vector columns will not "hit" on partials only full. At the moment I've dropped back to ilike %partial% until I can figure out this Trigram stuff. Just something to think about....
  • s

    stibbs

    10/29/2021, 4:58 AM
    I have a wide range of data length so probably need to use both
  • s

    Scott P

    10/29/2021, 10:19 PM
    It's possible to use the
    similarity
    extension like this:
    Copy code
    sql
    SELECT * FROM wines WHERE
      extensions.similarity(wines.description::TEXT, search_value) > 0.25
    You can also use something like the distance operator (from the
    pg_trgm
    extension I believe):
    Copy code
    sql
    SELECT * FROM wines WHERE
      1 - (wines.description::TEXT <-> search_value) > 0.25
    With enough fine tuning of the values (e.g.
    0.25
    ), you can have something that is akin to fuzzy searching, but the specific value you should use will depend on your dataset and your own testing. If you need something more advanced to search across multiple columns in a single function,
    to_tsvector
    and
    to_tsquery
    can be combined like this:
    Copy code
    sql
    SELECT * FROM wines WHERE
      to_tsvector(wines.name || ' ' || wines.description || ' ' || wines.manufacturer || ' ' || wines.country) -- concat columns, but be sure to include a space to separate them!
      @@ to_tsquery(search_value)
    In all 3 cases,
    search_value
    is a
    TEXT
    parameter passed into the function. You can of course combine any or all of the above options if you really need to using
    AND
    /
    OR
    .
    c
    g
    • 3
    • 7
  • g

    garyaustin

    10/29/2021, 10:52 PM
    Thanks for the detailed response. I'll get back to text search when I finish porting the rest of app from FB/ReactJS. I found Supabase, then in that process found Svelte from users here and am switching from React to that. My 60 year old brain finds it much easier to code and get cleaner results than with React. Luckily(?) my market is just now recovering from Covid so have time....
  • j

    javi

    10/30/2021, 8:31 AM
    wow this is so good, thank you for suck amazing response!!!
  • c

    chipilov

    10/30/2021, 8:48 AM
    Text and fuzzy search
  • t

    Thomas B

    10/30/2021, 12:39 PM
    Heya - a question about PostgreSQL Functions. 🙂 It is about the
    SECURITY DEFINER SET search_path = public
    thingy that I have to use when writing Functions when using Supabase, but I really do not see other tutorials or the like use.. Am I allowed to just add
    extensions
    to it along with public, or is there any security issues with that? I can only get pgjwt (https://github.com/michelp/pgjwt) to work with that added. 🙂 Here is the full function:
    Copy code
    CREATE OR REPLACE FUNCTION handle_new_user() RETURNS trigger
        SECURITY DEFINER SET search_path = public, extensions
    AS
    $$
    BEGIN
        INSERT INTO profiles (id, jwt)
        VALUES (NEW.id, (SELECT SIGN('{
          "sub": "1234567890",
          "name": "John Doe"
        }', 'secret')));
    
        RETURN NEW;
    END;
    $$ LANGUAGE plpgsql;
    g
    s
    • 3
    • 10
  • d

    dafri

    10/30/2021, 3:28 PM
    Hey! I have an issue when I try to link my local database to my supabase project. When I run
    supabase link --url 'postgresstring'
    I get the error
    Error: supabase_migrations.schema_migrations table conflicts with the contents of 'migrations' directory.
    Any idea what I have to do in this case?
  • h

    HarryET

    10/30/2021, 3:42 PM
    Are you trying to define a variable with SET or have i misunderstood?
  • g

    garyaustin

    10/30/2021, 4:03 PM
    Security Definer and search_path
1...212223...52Latest