Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove error check after result is obtained #201

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (c *Conn) QueryContext(ctx context.Context, query string, args []driver.Nam
return nil, ctx.Err()
}

go c.wrapQuery(ctx, os, dargs, rowsChan, errorChan)
go c.wrapQuery(os, dargs, rowsChan, errorChan)

var finalErr error
var finalRes driver.Rows
Expand Down Expand Up @@ -133,7 +133,7 @@ func (c *Conn) QueryContext(ctx context.Context, query string, args []driver.Nam

// wrapQuery is following the same logic as `stmt.Query()` except that we don't use a lock
// because the ODBC statement doesn't get exposed externally.
func (c *Conn) wrapQuery(ctx context.Context, os *ODBCStmt, dargs []driver.Value, rowsChan chan<- driver.Rows, errorChan chan<- error) {
func (c *Conn) wrapQuery(os *ODBCStmt, dargs []driver.Value, rowsChan chan<- driver.Rows, errorChan chan<- error) {
if err := os.Exec(dargs, c); err != nil {
errorChan <- err
return
Expand All @@ -146,12 +146,6 @@ func (c *Conn) wrapQuery(ctx context.Context, os *ODBCStmt, dargs []driver.Value

os.usedByRows = true
rowsChan <- &Rows{os: os}

// At the end of the execution, we check if the context has been cancelled
// to ensure the caller doesn't end up waiting for a message indefinitely (L119)
if ctx.Err() != nil {
errorChan <- ctx.Err()
}
}

// namedValueToValue is a utility function that converts a driver.NamedValue into a driver.Value.
Expand Down