https://supabase.com/ logo
Join DiscordCommunities
Powered by
# help
  • t

    tdwcks

    09/12/2021, 9:09 AM
    Thanks - It does the same thing unfortunately!
  • d

    dreinon

    09/12/2021, 3:54 PM
    Hi! I'm getting the following error with supabase-py trying to query a table with a relationship
  • d

    dreinon

    09/12/2021, 3:54 PM
    I tried reloading postgREST cache through sql queries and it didn't work, and I also tried to restart the server and it's also not working...
  • d

    dreinon

    09/12/2021, 3:56 PM
    I used the following https://postgrest.org/en/stable/schema_cache.html#schema-reloading
  • d

    dreinon

    09/12/2021, 3:57 PM
    Tried this
    NOTIFY pgrst, 'reload schema'
    and also tried to create an event trigger to restart the scheme cache automatically with:
    Copy code
    -- Create an event trigger function
    CREATE OR REPLACE FUNCTION public.pgrst_watch() RETURNS event_trigger
      LANGUAGE plpgsql
      AS $$
    BEGIN
      NOTIFY pgrst, 'reload schema';
    END;
    $$;
    
    -- This event trigger will fire after every ddl_command_end event
    CREATE EVENT TRIGGER pgrst_watch
      ON ddl_command_end
      EXECUTE PROCEDURE public.pgrst_watch();
  • b

    Brock

    09/12/2021, 10:15 PM
    Hello! I am trying to query some information across multiple tables. I am running into an issue that I think is revolving around the fact that my field of foreign keys is an array of UUIDs. So for instance, the following will return the array of uuids (field : assigned_departments).
    Copy code
    js
    await supabase.from('profiles').select(`
                id,
                first_name,
                last_name,
                assigned_departments
    But what I would like to do is use the UUID foreign key for the assigned_departments and query the department name. I tried the following:
    Copy code
    js
    await supabase.from('profiles').select(`
                id,
                first_name,
                last_name,
                assigned_departments (
                  id
                  department_name
                )
    But I get this error message as a response.
    Copy code
    js
    {
      "hint": "If a new foreign key between these entities was created in the database, try reloading the schema cache.",
      "message": "Could not find a relationship between profiles and assigned_departments in the schema cache"
    }
    I'm not sure how to reload the scheme cache or if I am just missing something?
  • d

    dreinon

    09/12/2021, 10:21 PM
    Same error as mine
  • d

    dreinon

    09/12/2021, 10:22 PM
    Not really sure if this is a bug. If it is, I can open an issue at GH
  • b

    Brock

    09/12/2021, 10:23 PM
    I'm not really sure if it is or not. This snippet seems similar from the official docs but no way to test it.
    Copy code
    const { data, error } = await supabase
      .from('countries')
      .select(`
        name,
        cities (
          name
        )
      `)
  • r

    RichCorbs

    09/12/2021, 10:53 PM
    Try
    assigned_departments!assigned_department(*)
    .
  • b

    Brock

    09/12/2021, 10:59 PM
    Same error message
  • b

    Brock

    09/12/2021, 11:19 PM
    UPDATE The following code block works after I set the id in the departments table to int8 and left assigned_departments as a single value and not an array. So the problem may come from either the field being an array or the id field being a UUID, or both.
    Copy code
    let { data: profiles, error } = await supabase.from('profiles').select(`
                id,
                first_name,
                last_name,
                assigned_departments (
                    id,
                department_name
                )
            `);
  • b

    Brock

    09/12/2021, 11:31 PM
    UPDATE 2 Okay i just changed it back so that the id field in the departments table was a UUID and then left the assigned_departments field as a single value and not an array and it works. So the problem must have to do with the array value field.
  • e

    erik_flywheel

    09/13/2021, 1:11 AM
    Hey everyone, I'm getting an error trying to password reset via postman {"code":401,"msg":"Invalid token: token contains an invalid number of segments"} It's the token directly from the URL... any guidance?
  • d

    dreinon

    09/13/2021, 1:43 AM
    @User whenever you have time, could you check my question and tell me if it's actually a bug to add it to GH, please? Thanks!
  • j

    jason-lynx

    09/13/2021, 1:48 AM
    yeah using the foreign key will need each value to be in its own row, instead of being an array
  • j

    jason-lynx

    09/13/2021, 1:50 AM
    if changing your data model to move away from an array isn't an option, you'll have to explode the the array before each query i.e.
    UNNEST
    in postgres https://www.postgresql.org/docs/current/functions-array.html
  • e

    everconfusedguy

    09/13/2021, 1:53 AM
    Hi @dreinon if you aren't sure it's a bug, create a github discussion and we will take a look
  • b

    Brock

    09/13/2021, 1:57 AM
    hmm I see, that's interesting
  • j

    jason-lynx

    09/13/2021, 2:05 AM
    would recommend not using an array though
  • b

    Brock

    09/13/2021, 2:08 AM
    So i'm not the best with databases, what would be the best way then for me to accomplish this relationship? where the field
    assigned_depts
    is one or many departments?
    j
    • 2
    • 6
  • b

    Brock

    09/13/2021, 2:09 AM
    this seems rather simple and im just being ignorant?
  • j

    jason-lynx

    09/13/2021, 2:23 AM
    db design
  • u

    user

    09/13/2021, 2:33 AM
    Does Supabase Auth handle roles?
  • s

    stibbs

    09/13/2021, 3:13 AM
    auth.users
    table does have a
    role
    column, but I think it is used more as a boolean for whether the user has validated their email? If you want to add roles, add your own
    public.users
    table and add the fields there, with link to the
    auth.users
    id
  • s

    stibbs

    09/13/2021, 3:15 AM
    FYI, to check what columns are included out of the box by supabase auth you can execute
    select * from auth.users;
    in the supabase SQL ui
  • l

    lnraahCC

    09/13/2021, 4:02 AM
    Hi guys, I got 2 application, they both connected to the same supabase service, A is for all user, B only for specific user. How can the supabase Auth only allow specific user to login to B???
  • m

    Miguel

    09/13/2021, 6:26 AM
    Why does this not work?
  • j

    jmnoz

    09/13/2021, 7:43 AM
    Maybe this isn't exactly as supabase question, but I'm using supabase sign in and google Oauth but I need to present my web app in an iFrame. Does anyone know how to do this?
  • s

    stibbs

    09/13/2021, 7:46 AM
    The "View data" link in the table editor isn't working. Is this a known issue?
1...848586...316Latest