(client: Client.SqlClient)
| 70 | |
| 71 | /** @internal */ |
| 72 | const makeSqlCommit = (client: Client.SqlClient) => { |
| 73 | return function(this: Compilable, plugins: ReadonlyArray<KyselyPlugin>) { |
| 74 | const { parameters, queryId, sql } = this.compile() |
| 75 | const execute = client.unsafe<Record<string, unknown>>(sql, parameters) |
| 76 | if (plugins.length === 0) return execute |
| 77 | return Effect.flatMap(execute, (rows) => |
| 78 | Effect.map( |
| 79 | Effect.reduce(plugins, { rows: Array.from(rows) } as QueryResult<Record<string, unknown>>, (result, plugin) => |
| 80 | Effect.tryPromise({ |
| 81 | try: () => |
| 82 | plugin.transformResult({ queryId, result }), |
| 83 | catch: (cause) => |
| 84 | new SqlError({ cause }) |
| 85 | })), |
| 86 | (result) => |
| 87 | result.rows |
| 88 | )) |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | /** @internal */ |
| 93 | function executeCommit(this: Executable) { |
no test coverage detected