Skip to content

Commit 131b7b5

Browse files
committed
[CALCITE-6862] Cleanup minor warnings
1 parent 85ac9ad commit 131b7b5

4 files changed

+13
-10
lines changed

connection.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ func (c *conn) exec(ctx context.Context, query string, args []namedValue) (drive
146146
}
147147

148148
statementID := st.(*message.CreateStatementResponse).GetStatementId()
149-
defer c.closeStatement(context.Background(), statementID)
149+
defer c.closeStatement(ctx, statementID)
150150

151151
res, err := c.httpClient.post(ctx, message.PrepareAndExecuteRequest_builder{
152152
ConnectionId: c.connectionId,
@@ -202,7 +202,7 @@ func (c *conn) query(ctx context.Context, query string, args []namedValue) (driv
202202
}.Build())
203203

204204
if err != nil {
205-
_ = c.closeStatement(context.Background(), statementID)
205+
_ = c.closeStatement(ctx, statementID)
206206
return nil, c.avaticaErrorToResponseErrorOrError(err)
207207
}
208208

@@ -247,7 +247,7 @@ func (c *conn) ResetSession(_ context.Context) error {
247247
}
248248

249249
func (c *conn) closeStatement(ctx context.Context, statementID uint32) error {
250-
_, err := c.httpClient.post(context.Background(), message.CloseStatementRequest_builder{
250+
_, err := c.httpClient.post(ctx, message.CloseStatementRequest_builder{
251251
ConnectionId: c.connectionId,
252252
StatementId: statementID,
253253
}.Build())

driver.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func NewConnector(dsn string) driver.Connector {
6464
}
6565
}
6666

67-
func (c *Connector) Connect(context.Context) (driver.Conn, error) {
67+
func (c *Connector) Connect(ctx context.Context) (driver.Conn, error) {
6868

6969
config, err := ParseDSN(c.dsn)
7070

@@ -99,7 +99,7 @@ func (c *Connector) Connect(context.Context) (driver.Conn, error) {
9999
if err != nil {
100100
return nil, err
101101
}
102-
response, err := conn.httpClient.post(context.Background(), message.DatabasePropertyRequest_builder{
102+
response, err := conn.httpClient.post(ctx, message.DatabasePropertyRequest_builder{
103103
ConnectionId: conn.connectionId,
104104
}.Build())
105105

driver_hsqldb_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ func TestHSQLDBDataTypes(t *testing.T) {
179179
booleanValue bool = true
180180
chValue string = "a"
181181
varcharValue string = "test string"
182-
binValue []byte = make([]byte, 20, 20)
182+
binValue []byte = make([]byte, 20)
183183
varbinValue []byte = []byte("testtesttest")
184184
dtValue time.Time = time.Date(2100, 2, 1, 0, 0, 0, 0, time.UTC)
185185
// tmValue time.Time = time.Date(0, 1, 1, 21, 21, 21, 222000000, time.UTC)

driver_phoenix_test.go

+7-4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"bytes"
2222
"crypto/sha256"
2323
"database/sql"
24+
goerrors "errors"
2425
"fmt"
2526
"os"
2627
"path/filepath"
@@ -178,7 +179,7 @@ func TestPhoenixDataTypes(t *testing.T) {
178179
utmstmpValue time.Time = time.Date(2100, 2, 1, 21, 21, 21, 222000000, time.UTC)
179180
varcharValue string = "test string"
180181
chValue string = "a"
181-
binValue []byte = make([]byte, 20, 20)
182+
binValue []byte = make([]byte, 20)
182183
varbinValue []byte = []byte("testtesttest")
183184
)
184185

@@ -1194,9 +1195,10 @@ func TestPhoenixOptimisticConcurrency(t *testing.T) {
11941195
dbt.Fatal("Expected an error, but did not receive any.")
11951196
}
11961197

1197-
errName := err.(errors.ResponseError).Name
1198+
var responseError errors.ResponseError
1199+
goerrors.As(err, &responseError)
11981200

1199-
if errName != "transaction_conflict_exception" {
1201+
if responseError.Name != "transaction_conflict_exception" {
12001202
dbt.Fatal("Expected transaction_conflict")
12011203
}
12021204
})
@@ -1364,7 +1366,8 @@ func TestPhoenixErrorCodeParsing(t *testing.T) {
13641366
t.Error("Expected error due to selecting from non-existent table, but there was no error.")
13651367
}
13661368

1367-
resErr, ok := err.(errors.ResponseError)
1369+
var resErr errors.ResponseError
1370+
ok := goerrors.As(err, &resErr)
13681371

13691372
if !ok {
13701373
t.Fatalf("Error type was not ResponseError")

0 commit comments

Comments
 (0)