drizzle-team / drizzle-team/drizzle-orm
[BUG]: drizzle-zod/-arktype/-valibot/-typebox don't handle the 6 Gel-only ColumnDataType variants added in #4172
- Dominant language
- TypeScript
- Stars
- 35.8k
- Forks
- 1.6k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 4
Description
### Report hasn't been filed before
I have verified that the bug I'm about to report hasn't been filed before (searched `gel unknown`, `columnToSchema gel`, `dateDuration`, `localDateTime schema`, `arktype gel`, `drizzle-zod gel` — no matching open or closed issues/PRs).
### What version of `drizzle-orm` are you using?
0.45.3 (current `main`, `9d6453215d18705986c2081124437bb6a03fb943`)
### What version of `drizzle-kit` are you using?
N/A — not involved in this bug (it's in the schema-integration packages' runtime `columnToSchema` logic, not migrations/introspection).
### Other packages
drizzle-zod@0.8.3, drizzle-arktype@0.1.3, drizzle-valibot@0.4.2, drizzle-typebox@0.3.3 (all current `main`)
### Describe the Bug
**Undesired behavior:** #4172 added the Gel dialect and six new `ColumnDataType` members for Gel-only temporal types — `dateDuration`, `duration`, `relDuration`, `localTime`, `localDate`, `localDateTime` (`drizzle-orm/src/column-builder.ts`). None of the four schema-integration packages were updated to handle them. Each package's `columnToSchema()` function branches on `column.dataType` with an `if`/`else if` chain that still only covers the original nine members (`array`, `number`, `bigint`, `boolean`, `date`, `string`, `json`, `custom`, `buffer`). A column built with one of the six new Gel types has no matching branch, so `schema` stays `undefined` through the whole chain and falls through to each package's final catch-all:
- `drizzle-zod/src/column.ts` (`columnToSchema`, line 70; fallback at lines 130-131): `schema = z.any();`
- `drizzle-arktype/src/column.ts` (`columnToSchema`, line 66; fallback at lines 121-122): `schema = type.unknown;`
- `drizzle-valibot/src/column.ts` (`columnToSchema`, line 73; fallback at lines 121-122): `schema = v.any();`
- `drizzle-typebox/src/column.ts` (`columnToSchema`, line 71; fallback at lines 136-137): `schema = t.Any();`
So `createSelectSchema`/`createInsertSchema`/`createUpdateSchema` silently produce a passthrough validator (accepts any value, validates nothing) for these columns instead of a real, type-appropriate schema — the same class of degradation the `date`/`string` branches exist to prevent for their own types.
**Steps to reproduce** (using `drizzle-zod`; the same shape reproduces identically in `drizzle-arktype`, `drizzle-valibot`, and `drizzle-typebox`):
```ts
import { gelTable, localDate } from 'drizzle-orm/gel-core';
import { createSelectSchema } from 'drizzle-zod';
const users = gelTable('users', {
bornOn: localDate('born_on'), // dataType: 'localDate', SQL type cal::local_date
});
const schema = createSelectSchema(users);
// schema.shape.bornOn is z.any() — accepts literally any value (a number, an
// object, `null` passed as a non-nullable field, anything) with zero runtime
// validation, instead of a schema that actually constrains to the LocalDate
// shape the column represents (analogous to how a `date`-typed column gets
// `z.date()`/`z.coerce.date()` from the very next branch in the same chain).
```
The same reproduction works with any of the other five variants (`duration()`, `dateDuration()`, `relativeDuration()`, `localTime()`, `localDateTime()` — see `drizzle-orm/src/gel-core/columns/`) and with the other three packages' equivalent `createSelectSchema`/`createInsertSchema` calls.
**Desired result:** each package's `columnToSchema` if-chain should have a matching branch for all six Gel-only variants, producing a real schema instead of the generic `any`/`unknown` fallback — consistent with how every other `ColumnDataType` member is handled today.
### Suggested fix direction
Add six branches to each of the four files' `columnToSchema` if-chains (`drizzle-zod/src/column.ts`, `drizzle-arktype/src/column.ts`, `drizzle-valibot/src/column.ts`, `drizzle-typebox/src/column.ts`), one per new `dataType` value (`'dateDuration' | 'duration' | 'relDuration' | 'localTime' | 'localDate' | 'localDateTime'`), each producing a schema appropriate to that library (e.g. a string-pattern schema for the ISO-8601-like duration/local-date/local-time text representations Gel's driver returns, mirroring the precision already given to `date`/`string`). This is the same fix shape repeated four times — one branch-set per package — since all four files share this if-chain structure.
Contributor guide
Research direction
Start with drizzle-orm/src/column-builder.ts and the Gel column definitions to understand the six new dataType values, then compare columnToSchema in drizzle-zod/src/column.ts, drizzle-arktype/src/column.ts, drizzle-valibot/src/column.ts, and drizzle-typebox/src/column.ts. Add handling for every listed variant with library-appropriate schemas, and verify the generated select, insert, and update schemas no longer use the generic fallbacks.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- backend-api-design, database
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100