Skip to content

Commit

Permalink
Handle 0 length batches of requests gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
Bowbaq committed Jun 10, 2020
1 parent 6980fa1 commit 41b7be9
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions spreadsheet.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,10 @@ type ValueUpdateRequest struct {
}

func (s *Sheet) BatchUpdateFromPositionIface(requests ...*ValueUpdateRequest) error {
if len(requests) == 0 {
return nil
}

updates := sheets.BatchUpdateValuesRequest{
ValueInputOption: "USER_ENTERED",
}
Expand Down Expand Up @@ -311,9 +315,13 @@ func (s *Sheet) Append(data [][]interface{}) error {
})
}

func (s *Spreadsheet) DoBatch(reqs ...*sheets.Request) (*sheets.BatchUpdateSpreadsheetResponse, error) {
func (s *Spreadsheet) DoBatch(requests ...*sheets.Request) (*sheets.BatchUpdateSpreadsheetResponse, error) {
if len(requests) == 0 {
return nil, nil
}

batchUpdateReq := sheets.BatchUpdateSpreadsheetRequest{
Requests: reqs,
Requests: requests,
IncludeSpreadsheetInResponse: true,
}

Expand Down

0 comments on commit 41b7be9

Please sign in to comment.