Not null must have default value as well?
Noob question. Does a "not null" value have to have a default value? For some reason it seems like the case. This insert snippet is not working. and giving me a
Object literal may only specify known properties, and email does not exist in type
and Object literal may only specify known properties, and first_name does not exist in type
When I comment out phone and email from my schema/make them both nullable/add a default value it doesn't give me this error.
schema.ts
10 Replies
Not null requires a value (by default your column is nullable).
Without a .default (or .$default, .$defaultFn), you have to provide a value.
It makes it require
Yeah I'm getting this error even when I pass values in on insert for email/password_hash so that's what's confusing.
I don't want email/password_hash to have default values, I want them to be not null and I pass their values in on insert
https://drizzle.run/r212ev8wolhh9fg4nn1esvr6
I set email to be not null (required on insert) and have no error.
Drizzle Run
yehia's playground - Drizzle Run
feel free to tell me if I misunderstood something
You're totally right and this is expected behavior. It may be something with my particular setup with NestJS. I'll see if there's something there
Have you found any solution, facing the same issue after upgrading drizzle orm to latest
I was missing this: https://orm.drizzle.team/docs/goodies#type-api
Drizzle ORM - Goodies
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
After having these types I use them like this
For update query?
facing the same as inferInsert wont work on update statement
Why not
Can you show me the error