Next.js Discord

Discord Forum

getting data from prismaClient says field might be null when it literally isn't in the schema

Unanswered
Pixiebob posted this in #help-forum
Open in Discord
PixiebobOP
i have this in my schema
model products {
  id             Int       @id @default(autoincrement())
  //some fields
  recommended    Boolean   @default(false)  
  //more fiels
}


so recommended is obviously NON NULL and it has a default value, i even see in my database as non null, but when i get the data from prismaClient it says that recommended is of type boolean | null

  const data = await prismaClient.products.findMany({
    where: {
      recommended: true,
    },
    select:{
      id:true,
      //other fields
      recommended:true,
    }
  });

i have another field marked as
  detail    String   @db.VarChar

in the schema but is also marked as potential null,

i did npx prisma db pull and npx prisma generate multiple times, still nothing

i already hate the fact that i have to cast Decimal to number, but this shouldn't be this way
btw i'm using postgres as a database

1 Reply

Dwarf Hotot
Where are you getting this null show the result