(t *testing.T)
| 691 | } |
| 692 | |
| 693 | func TestConnSendBatchQueryPartialReadInsert(t *testing.T) { |
| 694 | t.Parallel() |
| 695 | |
| 696 | ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second) |
| 697 | defer cancel() |
| 698 | |
| 699 | pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) { |
| 700 | sql := `create temporary table ledger( |
| 701 | id serial primary key, |
| 702 | description varchar not null, |
| 703 | amount int not null |
| 704 | );` |
| 705 | mustExec(t, conn, sql) |
| 706 | |
| 707 | batch := &pgx.Batch{} |
| 708 | batch.Queue("select 1 union all select 2 union all select 3") |
| 709 | batch.Queue("insert into ledger(description, amount) values($1, $2),($1, $2)", "q1", 1) |
| 710 | |
| 711 | br := conn.SendBatch(ctx, batch) |
| 712 | |
| 713 | rows, err := br.Query() |
| 714 | if err != nil { |
| 715 | t.Error(err) |
| 716 | } |
| 717 | rows.Close() |
| 718 | |
| 719 | ct, err := br.Exec() |
| 720 | if err != nil { |
| 721 | t.Error(err) |
| 722 | } |
| 723 | if ct.RowsAffected() != 2 { |
| 724 | t.Errorf("ct.RowsAffected() => %v, want %v", ct.RowsAffected(), 2) |
| 725 | } |
| 726 | |
| 727 | br.Close() |
| 728 | }) |
| 729 | } |
| 730 | |
| 731 | func TestTxSendBatch(t *testing.T) { |
| 732 | t.Parallel() |
nothing calls this directly
no test coverage detected