| 395 | |
| 396 | // Routed and traced as a statement is, without the connection wait time. |
| 397 | const queryTextValues = (sql: string, params?: ReadonlyArray<unknown>) => |
| 398 | Effect.withFiber((fiber) => |
| 399 | Effect.useSpan(fiber.getRef(Statement.SpanNameGenerator)(spanAttributes), { kind: "client" }, (span) => { |
| 400 | for (const [key, value] of spanAttributes) { |
| 401 | span.attribute(key, value) |
| 402 | } |
| 403 | span.attribute(ATTR_SQL_METHOD, "executeTextValues") |
| 404 | span.attribute(ATTR_DB_QUERY_TEXT, sql) |
| 405 | const run = (connection: Connection) => (connection as ConnectionImpl).connection.queryTextValues(sql, params) |
| 406 | const transaction = Context.getOrUndefined(fiber.context, client.transactionService) |
| 407 | const execute = transaction !== undefined |
| 408 | ? Effect.flatMap(Client.activeTransactionConnection(transaction), run) |
| 409 | : borrower !== undefined |
| 410 | ? borrower(run) |
| 411 | : Effect.scoped(Effect.flatMap(acquirer, run)) |
| 412 | return fiber.cache.tracerEnabled && fiber.getRef(Statement.SpanPropagationEnabled) |
| 413 | ? Effect.provideService(execute, Tracer.ParentSpan, span) |
| 414 | : execute |
| 415 | }) |
| 416 | ) |
| 417 | |
| 418 | return Object.assign( |
| 419 | client, |