© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•3y ago•
4 replies
b3z

insertID not returned correctly when using custom UUID

export const users = mysqlTable("users", {
  id: varchar("id", { length: 36 })
    .primaryKey()
    .default(sql`(uuid())`)
    .notNull(),
  email: varchar("email", { length: 255 }).notNull(),
  profileImageUrl: varchar("profile_image_url", { length: 255 }),
  name: varchar("name", { length: 255 }).notNull(),
});
export const users = mysqlTable("users", {
  id: varchar("id", { length: 36 })
    .primaryKey()
    .default(sql`(uuid())`)
    .notNull(),
  email: varchar("email", { length: 255 }).notNull(),
  profileImageUrl: varchar("profile_image_url", { length: 255 }),
  name: varchar("name", { length: 255 }).notNull(),
});


I have a schema where I have set the ID to be a uuid, this works fine and inserts give me the correct ids. On insert I want to get the ID of the inserted record so I can redirect to the correct page, which I thought would be available on insertId but what I get returned from there is just a number. Is there another way to get the actual id of the inserted record?
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

Custom UUID
Drizzle TeamDTDrizzle Team / help
3y ago
Using BIN_TO_UUID / UUID_TO_BIN
Drizzle TeamDTDrizzle Team / help
3y ago
Returned type inference when using tanstack query
Drizzle TeamDTDrizzle Team / help
2y ago
Type of relations when using with is not correctly set
Drizzle TeamDTDrizzle Team / help
2y ago