Skip to content

fix(drizzle-valibot): handle compound dataType strings for UUID and other columns#5458

Open
MaxwellCalkin wants to merge 1 commit intodrizzle-team:mainfrom
MaxwellCalkin:fix/valibot-uuid-compound-datatype
Open

fix(drizzle-valibot): handle compound dataType strings for UUID and other columns#5458
MaxwellCalkin wants to merge 1 commit intodrizzle-team:mainfrom
MaxwellCalkin:fix/valibot-uuid-compound-datatype

Conversation

@MaxwellCalkin
Copy link

Summary

Fixes #5338

When using drizzle-orm@1.0.0-beta.* with drizzle-valibot@0.4.2, createSelectSchema() produces v.any() (which becomes {} in OpenAPI) for UUID columns instead of the expected v.pipe(v.string(), v.uuid()).

Root cause

drizzle-orm beta changed column dataType from simple strings to compound strings:

Column Stable dataType Beta dataType
uuid() "string" "string uuid"
integer() "number" "number int32"
json() "json" "object json"
bytea() "buffer" "object buffer"

columnToSchema() in drizzle-valibot uses exact equality checks like column.dataType === 'string', which fails for "string uuid". The UUID column falls through all checks and lands on the v.any() fallback.

Fix

Extract the base type from the first word of column.dataType (e.g. "string uuid".split(' ')[0] = "string") before matching. This way both "string" (stable) and "string uuid" (beta) route to stringColumnToSchema(), which already handles PgUUID correctly via isColumnType().

Also added handling for the new "object <constraint>" compound types (buffer, date, json) that the beta uses.

Note

The same bug exists in drizzle-zod, drizzle-typebox, and drizzle-arktype — they all use the same column.dataType === '...' pattern. This PR only fixes drizzle-valibot as reported in the issue, but the same fix should be applied to the other packages.

Test plan

  • Existing tests continue to pass (they use stable dataType strings)
  • Verified that "string uuid".split(' ')[0] correctly extracts "string", routing UUID columns to stringColumnToSchema() which returns v.pipe(v.string(), v.uuid())
  • The fix is backward-compatible: for stable dataType values like "string", "string".split(' ')[0] = "string" — same result as before

…tibility

drizzle-orm beta (1.0.0-beta.*) changed column dataType from simple
strings like "string" to compound strings like "string uuid". This
caused columnToSchema() to skip the string handler for UUID columns
(and others), falling through to v.any() which produces {} in OpenAPI.

Extract the base type from the first word of column.dataType so both
"string" and "string uuid" route to stringColumnToSchema(), which
already handles PgUUID via isColumnType().

Also handle the new "object <constraint>" compound types (buffer,
date, json) that the beta uses instead of top-level dataType values.

Fixes drizzle-team#5338

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@chatgpt-codex-connector
Copy link

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: drizzle-valibot not generating correct shcemas

1 participant