Skip to content

[BUG]: Seed UUIDs not compatible with Zod/v4 #4551

@okydk

Description

@okydk

Report hasn't been filed before.

  • I have verified that the bug I'm about to report hasn't been filed before.

What version of drizzle-orm are you using?

0.43.1

What version of drizzle-kit are you using?

0.31.1

Other packages

[email protected], [email protected]

Describe the Bug

The UUIDs created via drizzle-seed isn't compatible with what is validated via drizzle-zod.

Probably due to RFC 4122 spec.

// Drizzle-seed generated
708257e5-e2b4-410c-65ec-c6a81590be17 (Reported as invalid)
    Version digit (13th): The character at the 13th position is '4' (708257e5-e2b4-**4**10c-65ec-c6a81590be17). This is correct for a version 4 UUID.
    Variant digit (17th): The character at the 17th position is '6' (708257e5-e2b4-410c-**6**5ec-c6a81590be17). This is not one of the allowed characters ('8', '9', 'a', or 'b') for an RFC 4122 compliant UUID. This is the most likely reason for the validation failure.

// crypto.randomUUID()
8fec6e81-233e-4a68-8a4d-3aa19dbb3816 (Accepted as valid)
    Version digit (13th): The character at the 13th position is '4' (8fec6e81-233e-**4**a68-8a4d-3aa19dbb3816). This is correct for a version 4 UUID.
    Variant digit (17th): The character at the 17th position is '8' (8fec6e81-233e-4a68-**8**a4d-3aa19dbb3816). This is one of the allowed characters ('8', '9', 'a', or 'b') for an RFC 4122 compliant UUID.

Sample schema:

export const page = pgTable('page', {
  id: uuid().defaultRandom().primaryKey(),
})

This wasn't an issues in the v3 of drizzle-zod.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions