You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by fr...@apache.org on 2025/02/25 22:57:22 UTC

(calcite-avatica-go) branch main updated: [CALCITE-6862] Cleanup minor warnings

This is an automated email from the ASF dual-hosted git repository.

francischuang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/calcite-avatica-go.git


The following commit(s) were added to refs/heads/main by this push:
     new 131b7b5  [CALCITE-6862] Cleanup minor warnings
131b7b5 is described below

commit 131b7b54574ff4c743ae1a52fae16b80e9d2d985
Author: Francis Chuang <fr...@apache.org>
AuthorDate: Wed Feb 26 09:56:05 2025 +1100

    [CALCITE-6862] Cleanup minor warnings
---
 connection.go          |  6 +++---
 driver.go              |  4 ++--
 driver_hsqldb_test.go  |  2 +-
 driver_phoenix_test.go | 11 +++++++----
 4 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/connection.go b/connection.go
index 29d6487..227f973 100644
--- a/connection.go
+++ b/connection.go
@@ -146,7 +146,7 @@ func (c *conn) exec(ctx context.Context, query string, args []namedValue) (drive
 	}
 
 	statementID := st.(*message.CreateStatementResponse).GetStatementId()
-	defer c.closeStatement(context.Background(), statementID)
+	defer c.closeStatement(ctx, statementID)
 
 	res, err := c.httpClient.post(ctx, message.PrepareAndExecuteRequest_builder{
 		ConnectionId:      c.connectionId,
@@ -202,7 +202,7 @@ func (c *conn) query(ctx context.Context, query string, args []namedValue) (driv
 	}.Build())
 
 	if err != nil {
-		_ = c.closeStatement(context.Background(), statementID)
+		_ = c.closeStatement(ctx, statementID)
 		return nil, c.avaticaErrorToResponseErrorOrError(err)
 	}
 
@@ -247,7 +247,7 @@ func (c *conn) ResetSession(_ context.Context) error {
 }
 
 func (c *conn) closeStatement(ctx context.Context, statementID uint32) error {
-	_, err := c.httpClient.post(context.Background(), message.CloseStatementRequest_builder{
+	_, err := c.httpClient.post(ctx, message.CloseStatementRequest_builder{
 		ConnectionId: c.connectionId,
 		StatementId:  statementID,
 	}.Build())
diff --git a/driver.go b/driver.go
index efadfda..963b486 100644
--- a/driver.go
+++ b/driver.go
@@ -64,7 +64,7 @@ func NewConnector(dsn string) driver.Connector {
 	}
 }
 
-func (c *Connector) Connect(context.Context) (driver.Conn, error) {
+func (c *Connector) Connect(ctx context.Context) (driver.Conn, error) {
 
 	config, err := ParseDSN(c.dsn)
 
@@ -99,7 +99,7 @@ func (c *Connector) Connect(context.Context) (driver.Conn, error) {
 	if err != nil {
 		return nil, err
 	}
-	response, err := conn.httpClient.post(context.Background(), message.DatabasePropertyRequest_builder{
+	response, err := conn.httpClient.post(ctx, message.DatabasePropertyRequest_builder{
 		ConnectionId: conn.connectionId,
 	}.Build())
 
diff --git a/driver_hsqldb_test.go b/driver_hsqldb_test.go
index 70dcff7..9011bd3 100644
--- a/driver_hsqldb_test.go
+++ b/driver_hsqldb_test.go
@@ -179,7 +179,7 @@ func TestHSQLDBDataTypes(t *testing.T) {
 			booleanValue bool      = true
 			chValue      string    = "a"
 			varcharValue string    = "test string"
-			binValue     []byte    = make([]byte, 20, 20)
+			binValue     []byte    = make([]byte, 20)
 			varbinValue  []byte    = []byte("testtesttest")
 			dtValue      time.Time = time.Date(2100, 2, 1, 0, 0, 0, 0, time.UTC)
 			// tmValue      time.Time = time.Date(0, 1, 1, 21, 21, 21, 222000000, time.UTC)
diff --git a/driver_phoenix_test.go b/driver_phoenix_test.go
index ae12cef..7821bf9 100644
--- a/driver_phoenix_test.go
+++ b/driver_phoenix_test.go
@@ -21,6 +21,7 @@ import (
 	"bytes"
 	"crypto/sha256"
 	"database/sql"
+	goerrors "errors"
 	"fmt"
 	"os"
 	"path/filepath"
@@ -178,7 +179,7 @@ func TestPhoenixDataTypes(t *testing.T) {
 			utmstmpValue  time.Time = time.Date(2100, 2, 1, 21, 21, 21, 222000000, time.UTC)
 			varcharValue  string    = "test string"
 			chValue       string    = "a"
-			binValue      []byte    = make([]byte, 20, 20)
+			binValue      []byte    = make([]byte, 20)
 			varbinValue   []byte    = []byte("testtesttest")
 		)
 
@@ -1194,9 +1195,10 @@ func TestPhoenixOptimisticConcurrency(t *testing.T) {
 			dbt.Fatal("Expected an error, but did not receive any.")
 		}
 
-		errName := err.(errors.ResponseError).Name
+		var responseError errors.ResponseError
+		goerrors.As(err, &responseError)
 
-		if errName != "transaction_conflict_exception" {
+		if responseError.Name != "transaction_conflict_exception" {
 			dbt.Fatal("Expected transaction_conflict")
 		}
 	})
@@ -1364,7 +1366,8 @@ func TestPhoenixErrorCodeParsing(t *testing.T) {
 		t.Error("Expected error due to selecting from non-existent table, but there was no error.")
 	}
 
-	resErr, ok := err.(errors.ResponseError)
+	var resErr errors.ResponseError
+	ok := goerrors.As(err, &resErr)
 
 	if !ok {
 		t.Fatalf("Error type was not ResponseError")