(t *testing.T)
| 653 | } |
| 654 | |
| 655 | func TestConnSendBatchQueryRowInsert(t *testing.T) { |
| 656 | t.Parallel() |
| 657 | |
| 658 | ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second) |
| 659 | defer cancel() |
| 660 | |
| 661 | pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) { |
| 662 | sql := `create temporary table ledger( |
| 663 | id serial primary key, |
| 664 | description varchar not null, |
| 665 | amount int not null |
| 666 | );` |
| 667 | mustExec(t, conn, sql) |
| 668 | |
| 669 | batch := &pgx.Batch{} |
| 670 | batch.Queue("select 1") |
| 671 | batch.Queue("insert into ledger(description, amount) values($1, $2),($1, $2)", "q1", 1) |
| 672 | |
| 673 | br := conn.SendBatch(ctx, batch) |
| 674 | |
| 675 | var value int |
| 676 | err := br.QueryRow().Scan(&value) |
| 677 | if err != nil { |
| 678 | t.Error(err) |
| 679 | } |
| 680 | |
| 681 | ct, err := br.Exec() |
| 682 | if err != nil { |
| 683 | t.Error(err) |
| 684 | } |
| 685 | if ct.RowsAffected() != 2 { |
| 686 | t.Errorf("ct.RowsAffected() => %v, want %v", ct.RowsAffected(), 2) |
| 687 | } |
| 688 | |
| 689 | br.Close() |
| 690 | }) |
| 691 | } |
| 692 | |
| 693 | func TestConnSendBatchQueryPartialReadInsert(t *testing.T) { |
| 694 | t.Parallel() |
nothing calls this directly
no test coverage detected