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
{{ message }}
Repository navigation
Null constraint violation on the fields error does not specify fields when the problem is a NOT NULL custom domain #7254
Inserts that violate a NULL constraint normally tell you which fields are the causing the problem.
However, if the constraint is caused by a custom Postgres domain, it does not tell you.
The message will be like this:
Invalid `prisma.schemaVersion.create()` invocation:
Null constraint violation on the fields: ()
at cb (/Users/andrepena/git/hyperforms/hyperforms-web/node_modules/@prisma/client/runtime/index.js:35101:17)
at processTicksAndRejections (internal/process/task_queues.js:95:5) {
code: 'P2011',
clientVersion: '2.23.0',
meta: { constraint: [] }
}
Note that the fields that caused the problem are omitted. Also, because I don't think it's possible to tell Prisma to show the raw SQL error, it's impossible to know where the problem is
How to reproduce
Create a postgres domain that does NOT accept NULL
CREATE DOMAIN public.nano_id VARCHAR(16) NOT NULL;
Use this domain in a table
CREATE TABLE public.schema_versions (
display_name character varying NOT NULL,
my_field public.nano_id
);
Try to create a record that does not include my_field. See that my_field itself is nullable. The problem is that the domain is not nullable.
Expected behavior
The original SQL error should not be omitted. Right now, it's impossible to see the original error message
SQL Error [23502]: ERROR: domain nano_id does not allow null values
If possible, it should list the error in the Null constraint error
Null constraint violation on the fields: (my_field)
changed the title [-]"Null constraint violation on the fields" error does not specify fields when the problem is a NOT NULL custom domain[/-][+]`Null constraint violation on the fields` error does not specify fields when the problem is a `NOT NULL` custom domain[/+]on Jan 30, 2024
Activity
pantharshit00 commentedon May 28, 2021
I don't think we properly support postgres domains right now so this is kind of expected.
I am marking this as a feature request.
janpio commentedon May 28, 2021
Related: #1796
[-]"Null constraint violation on the fields" error does not specify fields when the problem is a NOT NULL custom domain[/-][+]`Null constraint violation on the fields` error does not specify fields when the problem is a `NOT NULL` custom domain[/+]janpio commentedon Jan 30, 2024
This could also be a feature request to return the raw SQL error on
P2011.