Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected behavior for multiple operations on the same table #607

Open
2 tasks done
rkistner opened this issue Feb 23, 2025 · 0 comments
Open
2 tasks done

Unexpected behavior for multiple operations on the same table #607

rkistner opened this issue Feb 23, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@rkistner
Copy link

rkistner commented Feb 23, 2025

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

Multiple operations on the same "table" (PostgrestQueryBuilder instance) share state unexpectedly. If this is by design, it should be documented.

To Reproduce

Run the following code:

const table = supabase.from('mytable');
await table.update({a: 1}).eq('id', 1);
await table.update({a: 2}).eq('id', 2);

I'd expect this to do two separate operations: update mytable set a = 1 where id = 1, then update mytable set a = 2 where id = 2. What actually happens is the second operation is the equivalent of update mytable set a = 2 where id = 1 and id = 2, resulting in nothing being updated. Request logs show the search string for the PATCH request as ?id=eq.1&id=eq.2.

Expected behavior

The two operations on table should be independent, and not affect each other.

Screenshots

N/A

System information

  • OS: N/A
  • Browser: Tested on Chrome
  • Version of supabase-js: 2.48.1 / postgrest-js 1.18.1
  • Version of Node.js: N/A

Additional context

There is a simple workaround - refactor the code as follows:

await supabase.from('mytable').update({a: 1}).eq('id', 1);
await supabase.from('mytable').update({a: 2}).eq('id', 2);

It's difficult to tell whether this behavior is by design or a bug. But it's definitely not expected, and leads to difficult-to-debug issues.

I also tested the Dart postgrest package, and there the same code does work as expected (two independent operations).

I tested with update specifically, but I assume other operations such as select will likely have the same issue.

@rkistner rkistner added the bug Something isn't working label Feb 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant