© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•3y ago•
1 reply
Craig

Insert Schemas with onConflictDoUpdate

I'm trying to leverage the
onConflictDoUpdate
onConflictDoUpdate
method to update a record if it already exists. The problem is that I create an insert schema with
drizzle-zod
drizzle-zod
that enforces the non nullable fields are set. In the case where the record already exists, it is valid to pass in partial data to my function, but that then fails the insert schema validation.

Is there any way to parse the insert schema only if there is no conflict?

My current workaround is to separate the insert and update logic.
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

insert multiple rows - onConflictDoUpdate
Drizzle TeamDTDrizzle Team / help
2y ago
Insert multiple rows + onConflictDoUpdate
Drizzle TeamDTDrizzle Team / help
3y ago
onConflictDoUpdate
Drizzle TeamDTDrizzle Team / help
5w ago
Detect when onConflictDoUpdate does a insert vs a update
Drizzle TeamDTDrizzle Team / help
8mo ago