fix(drizzle-valibot): handle compound dataType strings for UUID and other columns#5458
Open
MaxwellCalkin wants to merge 1 commit intodrizzle-team:mainfrom
Open
Conversation
…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>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #5338
When using
drizzle-orm@1.0.0-beta.*withdrizzle-valibot@0.4.2,createSelectSchema()producesv.any()(which becomes{}in OpenAPI) for UUID columns instead of the expectedv.pipe(v.string(), v.uuid()).Root cause
drizzle-ormbeta changed columndataTypefrom simple strings to compound strings:dataTypedataTypeuuid()"string""string uuid"integer()"number""number int32"json()"json""object json"bytea()"buffer""object buffer"columnToSchema()indrizzle-valibotuses exact equality checks likecolumn.dataType === 'string', which fails for"string uuid". The UUID column falls through all checks and lands on thev.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 tostringColumnToSchema(), which already handlesPgUUIDcorrectly viaisColumnType().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, anddrizzle-arktype— they all use the samecolumn.dataType === '...'pattern. This PR only fixesdrizzle-valibotas reported in the issue, but the same fix should be applied to the other packages.Test plan
dataTypestrings)"string uuid".split(' ')[0]correctly extracts"string", routing UUID columns tostringColumnToSchema()which returnsv.pipe(v.string(), v.uuid())dataTypevalues like"string","string".split(' ')[0]="string"— same result as before