0

I use the @nuxtjs/supabase module (essentially supabase-js).

I have a table "challenges" and two join tables "profile_challenge" (to assign the challenge to a profile) and "challenge_category" (to assign categories to the challenge). Both of these join tables are identical and store only the respective ID's of both reference tables. The respective tables "categories" and "profiles" are very simplistic and only contain an id and some text columns.

I make a request like this:

.from('challenges').select('*, profiles(id, username), categories(title, image_url)')

While I get the correct category data, the profile data is somehow wrong. For all 4 challenges i get the same profile data, although 2 challenges are assigned (through the join table) to a different profile.

How could it be that the categories work fine, and an identical table & request does not?

On a seperate site, when i get a single challenge, i get the correct profile. Also getting the id's directly from the joining tables works fine.


Dump getting all the Challenges & Profiles

Dump getting all the Challenges & Profiles

.from('challenges').select(*, profiles(username)

Dump getting a single Challenge by ID & Profile

.from('challenges').select(*, profiles(username).eq('id', routeID).single()
dshukertjr
  • 15,244
  • 11
  • 57
  • 94
  • Hey, could you provide an overview of your complete schema? You can use something like https://supabase-schema.vercel.app/ or pg_dump. Thanks – thorwebdev Oct 10 '22 at 05:22

1 Answers1

0

I had this same problem, was hoping on an update of this issue. While I have no solution, I was able to find a workaround. If you can accept(or filter out yourself in code) another level of nesting, you can join through the join table explicitly.

so, where you have

.from('challenges').select('*, profiles(id, username), categories(title, image_url)')

it would be

.from('challenges').select('*, profile_challenge!inner(profile_id, profiles(id,username))') ...same for challenge_category

It's not ideal but it's able to tide me over until Supabase fixes it on their side.