Query reads the results from the next query in the batch as if the query has been sent with Query.
()
| 172 | |
| 173 | // Query reads the results from the next query in the batch as if the query has been sent with Query. |
| 174 | func (br *batchResults) Query() (Rows, error) { |
| 175 | query, arguments, ok := br.nextQueryAndArgs() |
| 176 | if !ok { |
| 177 | query = "batch query" |
| 178 | } |
| 179 | |
| 180 | if br.err != nil { |
| 181 | return &baseRows{err: br.err, closed: true}, br.err |
| 182 | } |
| 183 | |
| 184 | if br.closed { |
| 185 | alreadyClosedErr := fmt.Errorf("batch already closed") |
| 186 | return &baseRows{err: alreadyClosedErr, closed: true}, alreadyClosedErr |
| 187 | } |
| 188 | |
| 189 | rows := br.conn.getRows(br.ctx, query, arguments) |
| 190 | rows.batchTracer = br.conn.batchTracer |
| 191 | |
| 192 | if !br.mrr.NextResult() { |
| 193 | rows.err = br.mrr.Close() |
| 194 | if rows.err == nil { |
| 195 | rows.err = errors.New("no more results in batch") |
| 196 | } |
| 197 | rows.closed = true |
| 198 | |
| 199 | if br.conn.batchTracer != nil { |
| 200 | br.conn.batchTracer.TraceBatchQuery(br.ctx, br.conn, TraceBatchQueryData{ |
| 201 | SQL: query, |
| 202 | Args: arguments, |
| 203 | Err: rows.err, |
| 204 | }) |
| 205 | } |
| 206 | |
| 207 | return rows, rows.err |
| 208 | } |
| 209 | |
| 210 | rows.resultReader = br.mrr.ResultReader() |
| 211 | return rows, nil |
| 212 | } |
| 213 | |
| 214 | // QueryRow reads the results from the next query in the batch as if the query has been sent with QueryRow. |
| 215 | func (br *batchResults) QueryRow() Row { |
no test coverage detected