Skip to content

Unexpected behavior for multiple operations on the same table #607

Open
@rkistner

Description

@rkistner

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions