github.com/ydb-platform/ydb-go-sdk/v3@v3.57.0/tests/integration/table_bulk_upsert_test.go (about) 1 //go:build integration 2 // +build integration 3 4 package integration 5 6 import ( 7 "context" 8 "fmt" 9 "testing" 10 11 "github.com/ydb-platform/ydb-go-sdk/v3/table" 12 "github.com/ydb-platform/ydb-go-sdk/v3/table/types" 13 ) 14 15 func TestTableBulkUpsert(t *testing.T) { 16 scope := newScope(t) 17 driver := scope.Driver() 18 tablePath := scope.TablePath() 19 20 // upsert 21 var rows []types.Value 22 23 for i := int64(0); i < 10; i++ { 24 val := fmt.Sprintf("value for %v", i) 25 rows = append(rows, types.StructValue( 26 types.StructFieldValue("id", types.Int64Value(i)), 27 types.StructFieldValue("val", types.TextValue(val)), 28 )) 29 } 30 31 err := driver.Table().Do(scope.Ctx, func(ctx context.Context, s table.Session) error { 32 return s.BulkUpsert(ctx, tablePath, types.ListValue(rows...)) 33 }) 34 scope.Require.NoError(err) 35 }