(t *testing.T)
| 2643 | } |
| 2644 | |
| 2645 | func TestQueryMultipleResults(t *testing.T) { |
| 2646 | ctx := context.Background() |
| 2647 | runTestsWithMultiStatement(t, dsn, func(dbt *DBTest) { |
| 2648 | dbt.mustExec(` |
| 2649 | CREATE TABLE test ( |
| 2650 | id INT NOT NULL AUTO_INCREMENT, |
| 2651 | value VARCHAR(255), |
| 2652 | PRIMARY KEY (id) |
| 2653 | )`) |
| 2654 | conn, err := dbt.db.Conn(ctx) |
| 2655 | if err != nil { |
| 2656 | t.Fatalf("failed to connect: %v", err) |
| 2657 | } |
| 2658 | conn.Raw(func(conn any) error { |
| 2659 | //lint:ignore SA1019 this is a test |
| 2660 | qr := conn.(driver.Queryer) |
| 2661 | c := conn.(*mysqlConn) |
| 2662 | |
| 2663 | // Demonstrate that repeated queries reset the affectedRows |
| 2664 | for range 2 { |
| 2665 | _, err := qr.Query(` |
| 2666 | INSERT INTO test (value) VALUES ('a'), ('b'); |
| 2667 | INSERT INTO test (value) VALUES ('c'), ('d'), ('e'); |
| 2668 | `, nil) |
| 2669 | if err != nil { |
| 2670 | t.Fatalf("insert statements failed: %v", err) |
| 2671 | } |
| 2672 | if got, want := c.result.affectedRows, []int64{2, 3}; !reflect.DeepEqual(got, want) { |
| 2673 | t.Errorf("bad affectedRows: got %v, want=%v", got, want) |
| 2674 | } |
| 2675 | } |
| 2676 | return nil |
| 2677 | }) |
| 2678 | }) |
| 2679 | } |
| 2680 | |
| 2681 | func TestPingContext(t *testing.T) { |
| 2682 | runTestsParallel(t, dsn, func(dbt *DBTest, _ string) { |
nothing calls this directly
no test coverage detected