Skip to content

Commit c8b45f7

Browse files
authored
Fix cursor batch (#607)
1 parent d8d4036 commit c8b45f7

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

test/backup_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ import (
3030
"testing"
3131
"time"
3232

33+
"github.com/stretchr/testify/require"
34+
3335
driver "github.com/arangodb/go-driver"
3436
)
3537

@@ -800,7 +802,10 @@ func TestBackupRestoreWithViews(t *testing.T) {
800802
if err != nil {
801803
t.Fatalf("Failed to create query: %s", describe(err))
802804
}
803-
defer cursor.Close()
805+
defer func(cursor driver.Cursor) {
806+
err := cursor.Close()
807+
require.NoError(t, err)
808+
}(cursor)
804809

805810
var numDocumentsInView int
806811
_, err = cursor.ReadDocument(ctx, &numDocumentsInView)

v2/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
- Admin Cluster API support
2121
- Set Licence API support
2222
- Transparent compression of requests and responses (ArangoDBConfiguration.Compression)
23+
- Fix Cursor batch
2324

2425

2526
## [2.0.3](https://github.com/arangodb/go-driver/tree/v2.0.3) (2023-10-31)

v2/arangodb/cursor_impl.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ func (c *cursor) CloseWithContext(ctx context.Context) error {
8989
if err != nil {
9090
return err
9191
}
92+
c.closed = true
9293

9394
switch code := resp.Code(); code {
9495
case http.StatusAccepted:
95-
c.closed = true
9696
c.data = cursorData{}
9797
return nil
9898
default:
@@ -182,13 +182,16 @@ func (c *cursor) getNextBatch(ctx context.Context, retryBatchID string) error {
182182
c.retryData.currentBatchID = c.data.NextBatchID
183183
}
184184

185-
resp, err := connection.CallPost(ctx, c.db.connection(), url, &c.data, nil, c.db.modifiers...)
185+
var data cursorData
186+
187+
resp, err := connection.CallPost(ctx, c.db.connection(), url, &data, nil, c.db.modifiers...)
186188
if err != nil {
187189
return err
188190
}
189191

190192
switch code := resp.Code(); code {
191193
case http.StatusOK:
194+
c.data = data
192195
return nil
193196
default:
194197
return shared.NewResponseStruct().AsArangoErrorWithCode(code)

0 commit comments

Comments
 (0)