studio
studio copied to clipboard
Prisma Studio does violates NOT NULL constraints
I think there is a bug in Prisma. I have tried this with about three different databases services which use MySQL and PostgreSql and they all fail at the"NOT NULL" constraint. Yet I figured that this only happens within the Prisma Studio. If you insert an empty row in the database itself based on your Prisma schema as migrated it will complain about the NOT NULL Constraint violation. Therefore, I believe the bug dwells in the Prisma studio itself.
If you even try with MongoDB/Superbase the Prisma studio will still insert an empty string even if you set the NOT NULL constraint.
There is a bug in Prisma studio that inserts empty strings when NOT NULL has been set.
What exactly is the bug? What goes wrong that should not?
I have experience something similar in that a field that is NOT set to be null-able in schema can still have a null value when set in Prism Studio. It appears to be ignoring the constraint.
@janpio the bug still persists where you can add a null value to a not null constraint column from prisma studio
bumping the thread. Just came across the same thing
Can someone please describe the problem in way I can understand? Optimally include an example Prisma schema, and then explain exactly what actions in Prisma Studio lead to an error. Thank you.
Facing the same issue.
Created a model without optional fields. Went to prisma studio, added a record and allowed me to save null values where i didn't set ?
(optional) to those fields.
Am I doing something wrong ?
Example schema:
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model User {
uid String @id @default(uuid())
email String @unique
name String
phone String
verifiedLevel Int @default(1)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
ranches Ranch[]
source String
initialTasksCompleted Json
}
So for this user, name and phone for example should be required to create the record and not allow null values... Prisma Studio allowed the record creation with null values
Checked the migration.sql
:
-- CreateTable
CREATE TABLE "User" (
"uid" TEXT NOT NULL,
"email" TEXT NOT NULL,
"name" TEXT NOT NULL,
"phone" TEXT NOT NULL,
"verifiedLevel" INTEGER NOT NULL DEFAULT 1,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
"initialTasksCompleted" JSONB NOT NULL,
CONSTRAINT "User_pkey" PRIMARY KEY ("uid")
);