ReviewOS

stacks/bun-query-builder

Type the driver boundary (internal DriverConnection interface) to remove ~431 'as any'

#1044
Closed glennmichael123 opened this 22 days ago · 0 comments
22 days ago

Summary

The query-execution core casts the driver to any everywhere ((_sql as any).unsafe(...), (q as any).execute(), etc.) — ~431 in client.ts, ~50 in orm.ts. Because the SQLite wrapper (db.ts) and Bun's native SQL expose structurally different objects, there's no shared interface, so the dialect-dispatch hot path — where a multi-dialect builder most needs type safety — is entirely untyped.

Suggested fix

Define an internal DriverConnection/DriverQuery interface (unsafe, execute, cancel, then) that both createSQLiteSQL's return value and Bun's SQL satisfy, and type _sql/q against it. This eliminates most casts and would surface SQLite/Bun shape skew at compile time.

Severity: low/medium (type safety). Found via internal code audit.

Sign in to comment on this issue.