Skip to content

Fix cursor batch #607

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion test/backup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import (
"testing"
"time"

"github.com/stretchr/testify/require"

driver "github.com/arangodb/go-driver"
)

Expand Down Expand Up @@ -800,7 +802,10 @@ func TestBackupRestoreWithViews(t *testing.T) {
if err != nil {
t.Fatalf("Failed to create query: %s", describe(err))
}
defer cursor.Close()
defer func(cursor driver.Cursor) {
err := cursor.Close()
require.NoError(t, err)
}(cursor)

var numDocumentsInView int
_, err = cursor.ReadDocument(ctx, &numDocumentsInView)
Expand Down
1 change: 1 addition & 0 deletions v2/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- Admin Cluster API support
- Set Licence API support
- Transparent compression of requests and responses (ArangoDBConfiguration.Compression)
- Fix Cursor batch


## [2.0.3](https://github.com/arangodb/go-driver/tree/v2.0.3) (2023-10-31)
Expand Down
7 changes: 5 additions & 2 deletions v2/arangodb/cursor_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ func (c *cursor) CloseWithContext(ctx context.Context) error {
if err != nil {
return err
}
c.closed = true

switch code := resp.Code(); code {
case http.StatusAccepted:
c.closed = true
c.data = cursorData{}
return nil
default:
Expand Down Expand Up @@ -182,13 +182,16 @@ func (c *cursor) getNextBatch(ctx context.Context, retryBatchID string) error {
c.retryData.currentBatchID = c.data.NextBatchID
}

resp, err := connection.CallPost(ctx, c.db.connection(), url, &c.data, nil, c.db.modifiers...)
var data cursorData

resp, err := connection.CallPost(ctx, c.db.connection(), url, &data, nil, c.db.modifiers...)
if err != nil {
return err
}

switch code := resp.Code(); code {
case http.StatusOK:
c.data = data
return nil
default:
return shared.NewResponseStruct().AsArangoErrorWithCode(code)
Expand Down