| 111 | } |
| 112 | |
| 113 | async execute(placeholderValues: Record<string, unknown> | undefined = {}): Promise<T['execute']> { |
| 114 | return tracer.startActiveSpan('drizzle.execute', async (span) => { |
| 115 | const params = fillPlaceholders(this.params, placeholderValues); |
| 116 | const { fields, client, queryString, joinsNotNullableMap, customResultMapper, logger, typings } = this; |
| 117 | |
| 118 | span?.setAttributes({ |
| 119 | 'drizzle.query.text': queryString, |
| 120 | 'drizzle.query.params': JSON.stringify(params), |
| 121 | }); |
| 122 | |
| 123 | logger.logQuery(queryString, params); |
| 124 | |
| 125 | if (!fields && !customResultMapper) { |
| 126 | return tracer.startActiveSpan('drizzle.driver.execute', async () => { |
| 127 | const { rows } = await this.queryWithCache(queryString, params, async () => { |
| 128 | return await client(queryString, params as any[], 'execute', typings); |
| 129 | }); |
| 130 | |
| 131 | return rows; |
| 132 | }); |
| 133 | } |
| 134 | |
| 135 | const rows = await tracer.startActiveSpan('drizzle.driver.execute', async () => { |
| 136 | span?.setAttributes({ |
| 137 | 'drizzle.query.text': queryString, |
| 138 | 'drizzle.query.params': JSON.stringify(params), |
| 139 | }); |
| 140 | |
| 141 | const { rows } = await this.queryWithCache(queryString, params, async () => { |
| 142 | return await client(queryString, params as any[], 'all', typings); |
| 143 | }); |
| 144 | |
| 145 | return rows; |
| 146 | }); |
| 147 | |
| 148 | return tracer.startActiveSpan('drizzle.mapResponse', () => { |
| 149 | return customResultMapper |
| 150 | ? customResultMapper(rows) |
| 151 | : rows.map((row) => mapResultRow<T['execute']>(fields!, row, joinsNotNullableMap)); |
| 152 | }); |
| 153 | }); |
| 154 | } |
| 155 | |
| 156 | async all() { |
| 157 | } |