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, args []driver.NamedValue, )
| 123 | // |
| 124 | // QueryContext must honor the context timeout and return when it is canceled. |
| 125 | func (s *proxyStmt) QueryContext( |
| 126 | ctx context.Context, args []driver.NamedValue, |
| 127 | ) (driver.Rows, error) { |
| 128 | if IsRecording() { |
| 129 | var rows driver.Rows |
| 130 | var err error |
| 131 | if stmtCtx, ok := s.stmt.(driver.StmtQueryContext); ok { |
| 132 | rows, err = stmtCtx.QueryContext(ctx, args) |
| 133 | } else { |
| 134 | var vals []driver.Value |
| 135 | vals, err = namedValueToValue(args) |
| 136 | if err != nil { |
| 137 | return nil, err |
| 138 | } |
| 139 | rows, err = s.stmt.Query(vals) |
| 140 | } |
| 141 | |
| 142 | currentSession.AddRecord(&record{Typ: StmtQuery, Args: recordArgs{err}}) |
| 143 | if err != nil { |
| 144 | return nil, err |
| 145 | } |
| 146 | return &proxyRows{rows: rows}, nil |
| 147 | } |
| 148 | |
| 149 | rec, err := currentSession.VerifyRecord(StmtQuery) |
| 150 | if err != nil { |
| 151 | return nil, err |
| 152 | } |
| 153 | err, _ = rec.Args[0].(error) |
| 154 | if err != nil { |
| 155 | return nil, err |
| 156 | } |
| 157 | return &proxyRows{}, nil |
| 158 | } |
| 159 | |
| 160 | func namedValueToValue(named []driver.NamedValue) ([]driver.Value, error) { |
| 161 | dargs := make([]driver.Value, len(named)) |
nothing calls this directly
no test coverage detected