Skip to content

fix(db): export Drizzle's SQL, SQLWrapper, AnyColumn, and BatchItem types from void/db - #791

Merged
cpojer merged 1 commit into
voidzero-dev:mainfrom
karthickeyan-dev:fix/export-drizzle-types-790
Nov 11, 2026
Merged

cpojer merged 1 commit into
voidzero-dev:mainfrom
karthickeyan-dev:fix/export-drizzle-types-790

Conversation

@karthickeyan-dev

Copy link
Copy Markdown
Contributor

Closes #790

Summary

The database API reference says void/db re-exports Drizzle's operators "so you never need to depend on drizzle-orm directly". That stops being true once part of a query moves into a helper, because the only Drizzle type void/db exported was DrizzleD1Database.

  • packages/void/src/runtime/db.ts: re-export type AnyColumn, type SQL, type SQLWrapper from drizzle-orm and type BatchItem from drizzle-orm/batch. They are type-only, so the virtual void/db modules don't change.
  • packages/void/src/codegen/db-types.ts: the generated .void/db.d.ts replaces void/db's types through a tsconfig paths redirect, so it also re-exports these types from void/_db for every dialect. Without this, apps that have run void prepare would still not see them.
  • docs/reference/api/database.md: a note under Query Operators with an example.
import { posts } from '@schema';
import { db, sql, type BatchItem, type SQL, type SQLWrapper } from 'void/db';

function contains(column: SQLWrapper, text: string): SQL {
  return sql`instr(${column}, ${text}) > 0`;
}

const writes: [BatchItem<'sqlite'>, ...Array<BatchItem<'sqlite'>>] = [
  db.update(posts).set({ published: true }).where(contains(posts.title, 'void')),
];
await db.batch(writes);

BatchItem[] as written in the issue doesn't type-check against D1's db.batch(): the bare BatchItem covers every Drizzle dialect, and batch() takes a non-empty tuple. The docs example uses BatchItem<'sqlite'> in a non-empty tuple instead.

Verification

  • New test/unit/db-types.typecheck.ts covers the helper and batch patterns from the issue. I confirmed tsc checks the file.
  • plugin-drizzle.test.ts: asserts that the generated db.d.ts exports the types for sqlite, postgresql, and mysql.
  • Built packages/void and confirmed dist/runtime/db.d.mts exports all four types.
  • vp run check: 33/33 passed
  • vp test run: 792 files passed, 1 skipped

🤖 Generated with Claude Code

…ypes from void/db

Closes voidzero-dev#790

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@cpojer cpojer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@cpojer
cpojer merged commit f254d1e into voidzero-dev:main Nov 11, 2026
2 checks passed
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.

void/db doesn't export Drizzle's types (SQL, SQLWrapper, BatchItem)

2 participants