Skip to content
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
use QueryContext instead of Query in TestSimpleCommandOK and verify r…
…esult of rows closing there, add a comment explaining why we do not clear the destination before calling rows.Next() in TestReset
  • Loading branch information
zenovich committed Aug 26, 2025
commit 203cac4decba3cd53a4c0d585fb71eee7318ed68
10 changes: 7 additions & 3 deletions driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2353,17 +2353,19 @@ func TestSimpleCommandOK(t *testing.T) {
c := conn.(*mysqlConn)

// Issue a query that sets affectedRows and insertIds.
q, err := c.Query(`SELECT 1`, nil)
q, err := c.QueryContext(ctx, `SELECT 1`, nil)
if err != nil {
dbt.fail("Conn", "Query", err)
dbt.fail("Conn", "QueryContext", err)
}
if got, want := c.result.affectedRows, []int64{0}; !reflect.DeepEqual(got, want) {
dbt.Fatalf("bad affectedRows: got %v, want=%v", got, want)
}
if got, want := c.result.insertIds, []int64{0}; !reflect.DeepEqual(got, want) {
dbt.Fatalf("bad insertIds: got %v, want=%v", got, want)
}
q.Close()
if err := q.Close(); err != nil {
dbt.fail("Rows", "Close", err)
}

// Verify that Ping()/Reset() clears both fields.
for range 2 {
Expand Down Expand Up @@ -2437,6 +2439,8 @@ func TestReset(t *testing.T) {
if err != nil {
dbt.fail("Conn", "QueryContext", err)
}
// We intentionally do not clear the destination before calling Next()
// to make sure the SELECT really returns nil
err = rows.Next(result)
if err != nil {
dbt.fail("Rows", "Next", err)
Expand Down