Open
Description
Bug report
- I confirm this is a bug with Supabase, not with my own application.
- I confirm I have searched the Docs, GitHub Discussions, and Discord.
Describe the bug
Storing part of a query in a variable is a common pattern in Firebase development. Right now because our client library is not immutable, when you try to do this with Supabase client library, some of the information is kept in the original instance causing unexpected behaviors.
const restaurantsTable = supabase.from('restaurants')
const { data: restaurant } = await restaurantsTable.select().eq('id', id).single()
const { data: restaurants } = await restaurantsTable.select() // the query here will contain the `eq` and `single` statement from the previous line, therefore returning a single restaurant.
Expected behavior
Storing part of a query in a variable and running multiple queries using it should return the proper data.
const restaurantsTable = supabase.from('restaurants')
const { data: restaurant } = await restaurantsTable.select().eq('id', id).single()
const { data: restaurants } = await restaurantsTable.select() // `restaurants` contains the unfiltered query result.
Additional context
Maybe this is something to keep in mind when doing the next major release.