-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Bug report
Describe the bug
The onConflict
parameter is ignored in an upsert operation. Upserting a row only performs an update if the id is provided in the updated item and matches a previously inserted item.
This is due to the fact that the upsert handler only checks the id column to determine if an update should be performed.
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
- Insert an item
final data = {'user_id': 1, 'name': 'John Doe'};
const table = 'users';
// Insert a record
await mockSupabase.from(table).insert(data);
- Update the data for that item
final updatedData = {
...data,
'name': 'James Bond',
};
- Upsert the data specifying the
onConflict
column(s)
await mockSupabase.from(table).upsert(
updatedData,
onConflict: 'user_id',
);
- Select row based on expected unique column(s) returns multiple rows
final usersAfterUpdate =
await mockSupabase.from(table).select().eq('user_id', 1);
print(usersAfterUpdate.length); // 2
Expected behavior
The onConflict
parameter should be respected allowing updating an item based on a column(s) besides id
.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working