Skip to content

Commit 62e3395

Browse files
committed
fix BatchGet request grouping (#240)
1 parent 58b8919 commit 62e3395

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

batch_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,3 +188,14 @@ func TestBatchEmptyInput(t *testing.T) {
188188
t.Error("unexpected error", err)
189189
}
190190
}
191+
192+
func TestBatchGetInputSize(t *testing.T) {
193+
// see: https://github.com/guregu/dynamo/issues/240
194+
table := testDB.Table(testTableWidgets)
195+
keys := []Keyed{Keys{1, "abc"}, Keys{2, "def"}}
196+
batch := table.Batch("UserID", "Time").Get(keys...)
197+
input := batch.input(0)
198+
if size := len(input.RequestItems[testTableWidgets].Keys); size != len(keys) {
199+
t.Error("input amalgamation size mismatch. want:", len(keys), "got:", size)
200+
}
201+
}

batchget.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ func (bg *BatchGet) input(start int) *dynamodb.BatchGetItemInput {
232232
continue
233233
}
234234
kas.Keys = append(kas.Keys, get.keys())
235+
in.RequestItems[table] = kas
235236
}
236237
return in
237238
}

0 commit comments

Comments
 (0)