Skip to content

Commit 5fc8483

Browse files
crud: fix Get options
Before this patch, `vshard_router`, `fields`, `bucket_id`, `mode`, `prefer_replica`, `balance` were either ignored or had a wrong name. This patch fixes the issue.
1 parent f8ed81e commit 5fc8483

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ Versioning](http://semver.org/spec/v2.0.0.html) except to the first release.
5555
- Incorrect decoding of an MP_DECIMAL when the `scale` value is negative (#314)
5656
- Incorrect options (`after`, `batch_size` and `force_map_call`) setup for
5757
crud.SelectRequest (#320)
58+
- Incorrect options (`vshard_router`, `fields`, `bucket_id`, `mode`,
59+
`prefer_replica`, `balance`) setup for crud.GetRequest (#335)
5860

5961
## [1.12.0] - 2023-06-07
6062

crud/get.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,11 @@ func (opts GetOpts) EncodeMsgpack(enc *msgpack.Encoder) error {
4242
exists := [optsCnt]bool{}
4343
values[0], exists[0] = opts.Timeout.Get()
4444
values[1], exists[1] = opts.VshardRouter.Get()
45-
values[1], exists[1] = opts.BucketId.Get()
46-
values[2], exists[2] = opts.Mode.Get()
47-
values[3], exists[3] = opts.PreferReplica.Get()
48-
values[4], exists[4] = opts.Balance.Get()
45+
values[2], exists[2] = opts.Fields.Get()
46+
values[3], exists[3] = opts.BucketId.Get()
47+
values[4], exists[4] = opts.Mode.Get()
48+
values[5], exists[5] = opts.PreferReplica.Get()
49+
values[6], exists[6] = opts.Balance.Get()
4950

5051
return encodeOptions(enc, names[:], values[:], exists[:])
5152
}

crud/tarantool_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,27 @@ func TestStorageInfoResult(t *testing.T) {
808808
}
809809
}
810810

811+
func TestGetAdditionalOpts(t *testing.T) {
812+
conn := connect(t)
813+
defer conn.Close()
814+
815+
req := crud.MakeGetRequest(spaceName).Key(key).Opts(crud.GetOpts{
816+
Timeout: crud.MakeOptUint(1),
817+
Fields: crud.MakeOptTuple([]interface{}{"name"}),
818+
Mode: crud.MakeOptString("read"),
819+
PreferReplica: crud.MakeOptBool(true),
820+
Balance: crud.MakeOptBool(true),
821+
})
822+
resp := crud.Result{}
823+
824+
testCrudRequestPrepareData(t, conn)
825+
826+
err := conn.Do(req).GetTyped(&resp)
827+
if err != nil {
828+
t.Fatalf("Failed to Do CRUD request: %s", err)
829+
}
830+
}
831+
811832
// runTestMain is a body of TestMain function
812833
// (see https://pkg.go.dev/testing#hdr-Main).
813834
// Using defer + os.Exit is not works so TestMain body

0 commit comments

Comments
 (0)