* Executes a raw SQL query and returns the result set.
(executor: Statements, params: SqlQuery)
| 215 | * Executes a raw SQL query and returns the result set. |
| 216 | */ |
| 217 | async function executeQueryRaw(executor: Statements, params: SqlQuery): Promise<SqlResultSet> { |
| 218 | const { sql, args } = params |
| 219 | |
| 220 | try { |
| 221 | const convertedArgs = convertArgs(args, params.argTypes) |
| 222 | const result = await executor.query(sql, ...convertedArgs) |
| 223 | |
| 224 | // Collect all rows - the driver adapter interface requires synchronous access |
| 225 | const rows = await result.rows.collect() |
| 226 | // Map columns with type information |
| 227 | const columnNames = result.columns.map((col) => col.name) |
| 228 | const columnTypes = result.columns.map((col) => fieldToColumnType(col.oid)) |
| 229 | |
| 230 | return { |
| 231 | columnNames, |
| 232 | columnTypes, |
| 233 | rows: rows.map((row) => row.values), |
| 234 | } |
| 235 | } catch (error) { |
| 236 | throw convertDriverError(error) |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | /** |
| 241 | * Executes a raw SQL statement and returns the number of affected rows. |
no test coverage detected