-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
area: databaseSQL/database packageSQL/database packagepriority: highHigh priorityHigh prioritytype: bugSomething isn't workingSomething isn't working
Description
Problem
DatabaseInterface.query() returns a type that does not expose the .rows property, even though the PostgreSQL driver returns { rows: T[] } at runtime. Every downstream consumer must cast through any to access row data:
const result = await db.query(`SELECT ... FROM ...`, arg);
const rows = (result as any).rows ?? result; // forced castThis pattern appears in 5+ files across blindmanpress.com (and likely other consumers), completely defeating TypeScript safety on all raw query results.
Expected Behavior
query() return type should either:
- Expose
.rowsdirectly (e.g.,{ rows: T[] }) - Return rows as the top-level array (so no
.rowsaccess is needed) - Provide a typed
queryRows<T>()convenience method
Consumer Impact
Every file using db.query() with raw SQL currently has zero type safety on the result shape. Column renames or schema changes will not produce compile-time errors — only runtime failures.
Affected Consumer Files
billing/events/+page.server.tsreferrals/links/+server.tsreferrals/click/+server.tsaffiliates/events/+server.ts- Any file doing
const rows = (result as any).rows ?? result
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area: databaseSQL/database packageSQL/database packagepriority: highHigh priorityHigh prioritytype: bugSomething isn't workingSomething isn't working