Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-sqlite-bun-query-prepare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@effect/sql-sqlite-bun": patch
---

Wrap `db.query()` (prepare) errors in `SqlError` so they surface as catchable failures instead of defects.
12 changes: 6 additions & 6 deletions packages/sql-sqlite-bun/src/SqliteClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ export const make = (
) =>
Effect.withFiberRuntime<Array<any>, SqlError>((fiber) => {
const useSafeIntegers = Context.get(fiber.currentContext, Client.SafeIntegers)
const statement = db.query(sql)
// @ts-ignore bun-types missing safeIntegers method, fixed in https://github.com/oven-sh/bun/pull/26627
statement.safeIntegers(useSafeIntegers)
try {
const statement = db.query(sql)
// @ts-ignore bun-types missing safeIntegers method, fixed in https://github.com/oven-sh/bun/pull/26627
statement.safeIntegers(useSafeIntegers)
return Effect.succeed((statement.all(...(params as any)) ?? []) as Array<any>)
} catch (cause) {
return Effect.fail(new SqlError({ cause, message: "Failed to execute statement" }))
Expand All @@ -120,10 +120,10 @@ export const make = (
) =>
Effect.withFiberRuntime<Array<any>, SqlError>((fiber) => {
const useSafeIntegers = Context.get(fiber.currentContext, Client.SafeIntegers)
const statement = db.query(sql)
// @ts-ignore bun-types missing safeIntegers method, fixed in https://github.com/oven-sh/bun/pull/26627
statement.safeIntegers(useSafeIntegers)
try {
const statement = db.query(sql)
// @ts-ignore bun-types missing safeIntegers method, fixed in https://github.com/oven-sh/bun/pull/26627
statement.safeIntegers(useSafeIntegers)
return Effect.succeed((statement.values(...(params as any)) ?? []) as Array<any>)
} catch (cause) {
return Effect.fail(new SqlError({ cause, message: "Failed to execute statement" }))
Expand Down