drizzle-team / drizzle-team/drizzle-orm

[BUG]: drizzle-zod schema methods incorrectly set the field types to `Buffer` instead of correct types

Open
#4,705 17 comments 8 reactions 0 assignees View on GitHub
bug bug/fixed-in-beta drizzle/zod
Dominant language
TypeScript
Stars
35.8k
Forks
1.6k
Avg merge
2d 7h
Merged PRs (30d)
4

Description

### Report hasn't been filed before.

- [x] 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.42.0

### What version of `drizzle-kit` are you using?

0.31.0

### Other packages

drizzle-zod@0.8.2

### Describe the Bug

I am trying to use the `createSelectSchema` and `createInsertSchema` to produce validation schemas for my sqlite tables.

I have two Hono projects with the same dependencies, in one project it works correctly but in the other one it does not. When I copy the schema file from the non-working project to the working one it works.

Both projects use `typescript@5.8.3` and `zod@3.25.71` and I have ensured that my `{ z }` import is from `zod/v4`.

The contents of the `tsconfig.json` is the same in both projects
```json
{
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "Bundler",
"strict": true,
"skipLibCheck": true,
"lib": ["ESNext"],
"types": ["@cloudflare/workers-types/2023-07-01"],
"jsx": "react-jsx",
"jsxImportSource": "hono/jsx",
"baseUrl": "./",
"paths": {
"@/*": ["./src/*"]
}
}
}
```

I have created the following test table in both projects

```typescript
const exampleTable = sqliteTable('example', {
id: text('id').primaryKey(),
name: text('name').notNull(),
createdAt: integer('created_at', { mode: 'timestamp_ms' }).notNull(),
});

const exampleSchema = createSelectSchema(exampleTable);
type Example = z.infer;
```

In the working project the `Example` type has the following shape:
```typescript
type Example = {
id: string;
name: string;
createdAt: Date;
}
```

and in the non-working it looks like this:
```typescript
type Example = {
id: Buffer;
name: Buffer;
createdAt: Date;
}
```

I will also attach my dependencies which are the same across the two projects:

```json
"dependencies": {
"@hono/zod-openapi": "^0.19.4",
"@supabase/supabase-js": "^2.49.4",
"drizzle-orm": "^0.42.0",
"drizzle-zod": "^0.8.2",
"hono": "^4.7.7",
"hono-openapi": "^0.4.6",
"nanoid": "^5.1.5",
"stoker": "^1.4.2",
"zod": "^3.25.71"
},
"devDependencies": {
"@cloudflare/workers-types": "^4.20250214.0",
"@eslint/eslintrc": "^3.3.1",
"@eslint/js": "^9.25.1",
"@typescript-eslint/eslint-plugin": "^8.31.0",
"@typescript-eslint/parser": "^8.31.0",
"drizzle-kit": "^0.31.0",
"eslint": "^9.25.1",
"eslint-config-prettier": "^10.1.2",
"eslint-plugin-prettier": "^5.2.6",
"prettier": "^3.5.3",
"wrangler": "^4.4.0"
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.