QueryContext executes a query that may return rows, such as a SELECT. QueryContext must honor the context timeout and return when it is canceled.
( ctx context.Context, query string, args []driver.NamedValue, )
| 149 | // |
| 150 | // QueryContext must honor the context timeout and return when it is canceled. |
| 151 | func (c *proxyConn) QueryContext( |
| 152 | ctx context.Context, query string, args []driver.NamedValue, |
| 153 | ) (driver.Rows, error) { |
| 154 | if IsRecording() { |
| 155 | var rows driver.Rows |
| 156 | var err error |
| 157 | switch t := c.conn.(type) { |
| 158 | case driver.QueryerContext: |
| 159 | rows, err = t.QueryContext(ctx, query, args) |
| 160 | case driver.Queryer: |
| 161 | var vals []driver.Value |
| 162 | vals, err = namedValueToValue(args) |
| 163 | if err != nil { |
| 164 | return nil, err |
| 165 | } |
| 166 | rows, err = t.Query(query, vals) |
| 167 | default: |
| 168 | return nil, driver.ErrSkip |
| 169 | } |
| 170 | |
| 171 | currentSession.AddRecord(&record{Typ: ConnQuery, Args: recordArgs{query, err}}) |
| 172 | if err != nil { |
| 173 | return nil, err |
| 174 | } |
| 175 | return &proxyRows{rows: rows}, nil |
| 176 | } |
| 177 | |
| 178 | rec, err := currentSession.VerifyRecordWithStringArg(ConnQuery, query) |
| 179 | if err != nil { |
| 180 | return nil, err |
| 181 | } |
| 182 | err, _ = rec.Args[1].(error) |
| 183 | if err != nil { |
| 184 | return nil, err |
| 185 | } |
| 186 | return &proxyRows{}, nil |
| 187 | } |
| 188 | |
| 189 | // Close invalidates and potentially stops any current |
| 190 | // prepared statements and transactions, marking this |
nothing calls this directly
no test coverage detected