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

    Lothar

    01/31/2022, 10:22 PM
    and this is the
    ingredients
    table
  • l

    Lothar

    01/31/2022, 10:23 PM
    ingredients
    table has this content
  • l

    Lothar

    01/31/2022, 10:23 PM
    and
    ingredient-prints
    has this
  • s

    stabacco

    01/31/2022, 10:24 PM
    all looks good to me, when are you getting that error? during an insert?
  • l

    Lothar

    01/31/2022, 10:24 PM
    no, when trying to save this FK creation
  • l

    Lothar

    01/31/2022, 10:25 PM
    this is how it's currently. The FK is not created yet...
  • l

    Lothar

    01/31/2022, 10:26 PM
    I click on
    Add foreign key relation
    and I chose these values
  • l

    Lothar

    01/31/2022, 10:26 PM
    I then click
    Save
    and get the initial error I shared
  • s

    stabacco

    01/31/2022, 10:27 PM
    could you maybe remove that column and recreate it with the foreign key?
  • s

    stabacco

    01/31/2022, 10:28 PM
    it could be due to the field being nullable, in case you already have some entries
  • l

    Lothar

    01/31/2022, 10:29 PM
    but it's not nullable... you can see the
    Allow Nullable
    is not checked
  • l

    Lothar

    01/31/2022, 10:31 PM
    looks like removing and recreating with the FK works... no issue here because I had just 10 rows... but I can't see that happening if I had more rows....
  • l

    Lothar

    01/31/2022, 10:31 PM
    is this expected???
  • s

    stabacco

    01/31/2022, 10:33 PM
    this is postgres related, nothing to do with supabase. maybe have a look at stackoverflow for that error to figure out what the problem was in the first place
  • s

    stabacco

    01/31/2022, 10:35 PM
    my hunch is that some of those values that you already had filled in the
    master
    field were not matching any value in the other column from the other table, so the forign key could not resolve proeprly
  • l

    Lothar

    01/31/2022, 10:35 PM
    alright... thank you for your help with the workaround
  • l

    Lothar

    01/31/2022, 10:35 PM
    noup... it was a single value
  • l

    Lothar

    01/31/2022, 10:35 PM
    but no worries...
  • s

    stabacco

    01/31/2022, 10:36 PM
    null values would have been a problem
  • l

    Lothar

    01/31/2022, 10:36 PM
    there were no null values 😅
  • l

    Lothar

    01/31/2022, 10:37 PM
    supabase related... do you know if it's possible to have the foreign table contents come back in the same level as the main object?
  • l

    Lothar

    01/31/2022, 10:37 PM
    example...
  • l

    Lothar

    01/31/2022, 10:38 PM
    Copy code
    let { data, error, status } = await supabase
          .from('ingredient-prints')
          .select(`*, 
            ingredients (key) 
          `)
          .in('token',tokens)
          .limit(count)
    this, is returning this:
    Copy code
    {
      "edition": 9,
      "sent": null,
      "recipient": null,
      "from": null,
      "token": "7VTYM6wBgv25Hd9KHmTVQpVwqMDkAq6ctWqQDdX63PV7",
      "master": "DpPbk6h3UhYkAtZxj6Sxzt2bh9QMiqDN68wn9YaVQpBw",
      "ingredients": {
        "key": "doom-chalice"
      }
    }
    would it be possible to return it as
    Copy code
    {
      "edition": 9,
      "sent": null,
      "recipient": null,
      "from": null,
      "token": "7VTYM6wBgv25Hd9KHmTVQpVwqMDkAq6ctWqQDdX63PV7",
      "master": "DpPbk6h3UhYkAtZxj6Sxzt2bh9QMiqDN68wn9YaVQpBw",
      "key": "doom-chalice"
    }
    ?
  • s

    silentworks

    01/31/2022, 10:44 PM
    Please use threads folks, it's easier to keep track of conversations there.
  • w

    Will Lutz

    02/01/2022, 1:33 AM
    Anyone have a good article or video on Column Level Security? I am a SQL newbie but want to open up reading permissions on a specific column. Bonus points if it is through the supabase cloud UI.
    g
    • 2
    • 4
  • b

    bernat

    02/01/2022, 1:43 AM
    Hi there! Loving supabase so far but I'm struggling with inner joins. Below is an example query that's working on my supabase SQL editor
    Copy code
    sql
    select p.*
    from follows f
    join profile p on p.id = f.target_user_id
    where f.user_id = '9e7486c7-40f2-41dc-9a4d-467fbe52faee'
    I'd love to transform that into a js client select statement. Below is one of my attempts.
    Copy code
    js
    await supabase
        .from('profile')
        .select('*, follows!inner(id)')
        .eq('follows.user_id', user_id)
    Could someone be so kind to help me figure out the exact statement to use? Thanks! profile.id is a foreign key of user.id follows.user_id is a foreign key of user.id
  • s

    Subramanya Chakravarthy

    02/01/2022, 2:11 AM
    My project got deleted after few days of not using it. How can I restore it?
  • a

    AmusedGrape

    02/01/2022, 3:20 AM
    is there a way i can get a user from auth.users? i have a foreign-key for setting the user in a column, but i want to get that user's data (i.e. identity data)
    g
    • 2
    • 9
  • a

    AmusedGrape

    02/01/2022, 3:21 AM
    (or is it better to do something like this https://nikofischer.com/supabase-how-to-query-users-table)
  • g

    garyaustin

    02/01/2022, 3:45 AM
    User data from Auth
1...210211212...316Latest