You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to bulk update, but must use upsert. I use upsert but receive issues on non-null columns when they are not provided, despite the value existing on the record in the db.
To Reproduce
Example table:
CREATE TABLE test_table (
id text primary key,
other_column text null,
name text not null --<--- The problem
);
INSERT INTO test_table (id, other_column, name)
VALUES ('id1',null,'some_name');
Updating a single row (via upsert): I know the record exists and the name column is populated. However if I try to upsert:
{
code: '23502',
details: 'Failing row contains (id1, other_column_text, null).',
hint: null,
message: 'null value in column "name" of relation "test_table" violates not-null constraint'
}
Expected behavior
The row show be "merged", thus it should just update the two columns I provided, and not default the name column to null, which in this case is not allowed.
MaximusMcCann
changed the title
Upsert failing on null value column, even though value exists in db
Upsert failing on non-null column, even though value exists in db
Jan 25, 2024
I'm seeing very broken behavior with upsert, possibly related. I have a trigger that checks if the incoming NEW.version < OLD.version to reject updates from clients without the latest data. When I use upsert NEW.version is somehow set to the wrong value even though I've verified that the data I pass to upsert is correct! I pass { ...rest_of_record, version: 4 } to upsert and my trigger fails because NEW.version is 1 not 4.
Bug report
Describe the bug
I want to bulk
update
, but must useupsert
. I useupsert
but receive issues on non-null columns when they are not provided, despite the value existing on the record in the db.To Reproduce
Example table:
Updating a single row (via
upsert
): I know the record exists and thename
column is populated. However if I try toupsert
:I receive
Expected behavior
The row show be "merged", thus it should just update the two columns I provided, and not default the
name
column to null, which in this case is not allowed."@supabase/supabase-js": "^2.39.2",
The text was updated successfully, but these errors were encountered: