supabase / supabase-js

An isomorphic Javascript client for Supabase. Query your Supabase database, subscribe to realtime events, upload and download files, browse typescript examples, invoke postgres functions via rpc, invoke supabase edge functions, query pgvector.
https://supabase.com
MIT License
2.86k stars 220 forks source link

Return format is not consistent across queries with the same select parameters #972

Closed Wursteintopf closed 3 months ago

Wursteintopf commented 3 months ago

Bug report

Describe the bug

The returned results of a query differ based on whether that query is filtered on a related property or not.

To Reproduce

I want to create a query in which I sometimes filter by certain properties and sometimes I don't, as such:

const getItem = async (relatedItemName?: string) => {
  const client = createClient();

  let query = client.from("item").select("*, related_item(*)");

  if (relatedItemName) query = query.filter("related_item.name", "eq", relatedItemName);

  const { data } = await query;

  return data;
};

If I run this function without providing the relatedItemName property everything works as expected. As soon as I pass in the name and thus filter by it then the related_item property returns null for all items but the very first one.

Expected behavior

Both queries should return both the original item aswell as the related item.

System information

Additional context

If this is an Issue with PostgREST rather than with the supabase client, feel free to tell me, then I will move the issue over there.

Wursteintopf commented 3 months ago

Nevermind. I just realized that I specifically need to specify that I want an inner join, when filtering on a related property.