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

Pass context correctly #116

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ lint:
golangci-lint run --print-issued-lines=false ./...

test:
go test -v -coverprofile=coverage.out ./...
go test -count 1 -v -p 1 -coverprofile=coverage.out ./...

testshort:
go test -v -short -coverprofile=coverage.out ./...
go test -count 1 -v -short -coverprofile=coverage.out ./...

coverage: test
go tool cover -html=coverage.out -o coverage.html
22 changes: 18 additions & 4 deletions doc/changes/changes_1.0.9.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
# Exasol Driver go 1.0.9, released 2024-??-??
# Exasol Driver go 1.0.9, released 2024-06-27

Code name:
Code name: Fix reading int values

## Summary

## Features
This release fixes an issue when calling `rows.Scan(&result)` with an int value. This failed for large values like 100000000 with the following error:

* ISSUE_NUMBER: description
```
sql: Scan error on column index 0, name "COL": converting driver.Value type float64 ("1e+08") to a int64: invalid syntax
```

Please note that reading non-integer numbers like `1.1` into a `int64` variable will still fail with the following error message:

```
sql: Scan error on column index 0, name "COL": converting driver.Value type string ("1.1") to a int64: invalid syntax
```

The release also now returns the correct error from `rows.Err()`. Before, this only returned `driver.ErrBadConn`.

## Bugfixes

* #113: Fixed `Scan()` with large integer numbers
* #111: Return correct error from `rows.Err()`
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@ require (
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/stretchr/objx v0.5.2 // indirect
golang.org/x/net v0.26.0 // indirect
)
12 changes: 4 additions & 8 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

195 changes: 141 additions & 54 deletions itest/integration_test.go

Large diffs are not rendered by default.

26 changes: 16 additions & 10 deletions pkg/connection/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ func (c *Connection) ExecContext(ctx context.Context, query string, args []drive
}

func (c *Connection) Exec(query string, args []driver.Value) (driver.Result, error) {
return c.exec(context.Background(), query, args)
return c.exec(c.Ctx, query, args)
}

func (c *Connection) Query(query string, args []driver.Value) (driver.Rows, error) {
return c.query(context.Background(), query, args)
return c.query(c.Ctx, query, args)
}

func (c *Connection) PrepareContext(ctx context.Context, query string) (driver.Stmt, error) {
Expand All @@ -64,7 +64,7 @@ func (c *Connection) PrepareContext(ctx context.Context, query string) (driver.S
if err != nil {
return nil, err
}
return c.createStatement(response), nil
return c.createStatement(ctx, response), nil
}

func (c *Connection) createPreparedStatement(ctx context.Context, query string) (*types.CreatePreparedStatementResponse, error) {
Expand All @@ -82,16 +82,22 @@ func (c *Connection) createPreparedStatement(ctx context.Context, query string)
return response, nil
}

func (c *Connection) createStatement(result *types.CreatePreparedStatementResponse) *Statement {
return NewStatement(c, result)
func (c *Connection) createStatement(ctx context.Context, result *types.CreatePreparedStatementResponse) *Statement {
return NewStatement(ctx, c, result)
}

func (c *Connection) Ping(ctx context.Context) error {
fmt.Printf("Ping\n")
// FIXME
return nil
}

func (c *Connection) Prepare(query string) (driver.Stmt, error) {
return c.PrepareContext(context.Background(), query)
return c.PrepareContext(c.Ctx, query)
}

func (c *Connection) Close() error {
return c.close(context.Background())
return c.close(c.Ctx)
}

func (c *Connection) Begin() (driver.Tx, error) {
Expand All @@ -102,7 +108,7 @@ func (c *Connection) Begin() (driver.Tx, error) {
if c.Config.Autocommit {
return nil, errors.ErrAutocommitEnabled
}
return NewTransaction(c), nil
return NewTransaction(c.Ctx, c), nil
}

func (c *Connection) query(ctx context.Context, query string, args []driver.Value) (driver.Rows, error) {
Expand All @@ -125,15 +131,15 @@ func (c *Connection) query(ctx context.Context, query string, args []driver.Valu
if err != nil {
return nil, err
}
return ToRow(result, c)
return ToRow(ctx, result, c)
}

func (c *Connection) executeSimpleWithRows(ctx context.Context, query string) (driver.Rows, error) {
result, err := c.SimpleExec(ctx, query)
if err != nil {
return nil, err
}
return ToRow(result, c)
return ToRow(ctx, result, c)
}

func (c *Connection) executePreparedStatement(ctx context.Context, s *types.CreatePreparedStatementResponse, args []driver.Value) (*types.SqlQueriesResponse, error) {
Expand Down
Loading
Loading