(query: string, params: ReadonlyArray<unknown>)
| 664 | private readonly reserve: Effect.Effect<Pg.ClientBase, SqlError, Scope.Scope> |
| 665 | |
| 666 | private run(query: string, params: ReadonlyArray<unknown>) { |
| 667 | return this.runWithClient<ReadonlyArray<any>>((client, resume) => { |
| 668 | client.query(query, params as any, (err, result) => { |
| 669 | if (err) { |
| 670 | resume( |
| 671 | Effect.fail(new SqlError({ reason: classifyError(err, "Failed to execute statement", "execute") })) |
| 672 | ) |
| 673 | } else { |
| 674 | // Multi-statement queries return an array of results |
| 675 | resume(Effect.succeed( |
| 676 | Array.isArray(result) |
| 677 | ? result.map((r) => r.rows ?? []) |
| 678 | : result.rows ?? [] |
| 679 | )) |
| 680 | } |
| 681 | }) |
| 682 | }) |
| 683 | } |
| 684 | |
| 685 | execute( |
| 686 | sql: string, |
no test coverage detected