Upsert returning null value error #15730
-
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
Hello, Can you try with const { error } = await supabase
.from('my_table')
.upsert([{ id: 3, name: 'Abc' }, { name: 'Def' }], { onConflict: 'name', defaultToNull: false}); This is a recent feature so you might have to upgrade your instance by pausing/unpausing. |
Beta Was this translation helpful? Give feedback.
-
I spent time debugging a similar issue because the documentation is not clear about this option. At least not about what is the default value of the option. |
Beta Was this translation helpful? Give feedback.
-
Hey, I'm facing the same issue even if I use Client version: Here's my table definition CREATE TABLE my_table (
id UUID UNIQUE PRIMARY KEY DEFAULT uuid_generate_v4(),
name VARCHAR(255) NOT NULL,
description VARCHAR(3000) NOT NULL
); But after running this in the Supabase editor, when I inspect the definition on the Supabase UI I see that the the table definition has a NOT NULL constraint id uuid not null default uuid_generate_v4 (), And here's the response I get if I don't provide the id on my upsert. {
"code":"23502",
"details":"Failing row contains (null, Not working, Annoying).",
"hint":null,
"message":"null value in column \"id\" of relation \"my_table\" violates not-null constraint"
} |
Beta Was this translation helpful? Give feedback.
Hello,
Can you try with
defaultToNull: false
?This is a recent feature so you might have to upgrade your instance by pausing/unpausing.