Skip to content

Commit 41bb312

Browse files
Fix the merge
Signed-off-by: Yury-Fridlyand <yury.fridlyand@improving.com>
1 parent 864e8f3 commit 41bb312

File tree

3 files changed

+25
-59
lines changed

3 files changed

+25
-59
lines changed

go/api/base_client.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2819,7 +2819,7 @@ func (client *baseClient) Sort(key string) ([]Result[string], error) {
28192819
if err != nil {
28202820
return nil, err
28212821
}
2822-
return handleStringArrayResponse(result)
2822+
return handleStringOrNilArrayResponse(result)
28232823
}
28242824

28252825
func (client *baseClient) SortWithOptions(key string, options *options.SortOptions) ([]Result[string], error) {
@@ -2828,15 +2828,15 @@ func (client *baseClient) SortWithOptions(key string, options *options.SortOptio
28282828
if err != nil {
28292829
return nil, err
28302830
}
2831-
return handleStringArrayResponse(result)
2831+
return handleStringOrNilArrayResponse(result)
28322832
}
28332833

28342834
func (client *baseClient) SortReadOnly(key string) ([]Result[string], error) {
28352835
result, err := client.executeCommand(C.SortReadOnly, []string{key})
28362836
if err != nil {
28372837
return nil, err
28382838
}
2839-
return handleStringArrayResponse(result)
2839+
return handleStringOrNilArrayResponse(result)
28402840
}
28412841

28422842
func (client *baseClient) SortReadOnlyWithOptions(key string, options *options.SortOptions) ([]Result[string], error) {
@@ -2845,26 +2845,26 @@ func (client *baseClient) SortReadOnlyWithOptions(key string, options *options.S
28452845
if err != nil {
28462846
return nil, err
28472847
}
2848-
return handleStringArrayResponse(result)
2848+
return handleStringOrNilArrayResponse(result)
28492849
}
28502850

2851-
func (client *baseClient) SortStore(key string, destination string) (Result[int64], error) {
2851+
func (client *baseClient) SortStore(key string, destination string) (int64, error) {
28522852
result, err := client.executeCommand(C.Sort, []string{key, "STORE", destination})
28532853
if err != nil {
2854-
return CreateNilInt64Result(), err
2854+
return defaultIntResponse, err
28552855
}
2856-
return handleIntOrNilResponse(result)
2856+
return handleIntResponse(result)
28572857
}
28582858

28592859
func (client *baseClient) SortStoreWithOptions(
28602860
key string,
28612861
destination string,
28622862
options *options.SortOptions,
2863-
) (Result[int64], error) {
2863+
) (int64, error) {
28642864
optionArgs := options.ToArgs()
28652865
result, err := client.executeCommand(C.Sort, append([]string{key, "STORE", destination}, optionArgs...))
28662866
if err != nil {
2867-
return CreateNilInt64Result(), err
2867+
return defaultIntResponse, err
28682868
}
2869-
return handleIntOrNilResponse(result)
2869+
return handleIntResponse(result)
28702870
}

go/api/generic_base_commands.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -613,11 +613,10 @@ type GenericBaseCommands interface {
613613
// Example:
614614
//
615615
// result, err := client.SortStore("key","destkey")
616-
// result.Value(): 1
617-
// result.IsNil(): false
616+
// result: 1
618617
//
619618
// [valkey.io]: https://valkey.io/commands/sort/
620-
SortStore(key string, destination string) (Result[int64], error)
619+
SortStore(key string, destination string) (int64, error)
621620

622621
// Sorts the elements in the list, set, or sorted set at key and stores the result in
623622
// destination. The sort command can be used to sort elements based on
@@ -648,11 +647,10 @@ type GenericBaseCommands interface {
648647
//
649648
// options := api.NewSortOptions().SetByPattern("weight_*").SetIsAlpha(false).AddGetPattern("object_*").AddGetPattern("#")
650649
// result, err := client.SortStore("key","destkey",options)
651-
// result.Value(): 1
652-
// result.IsNil(): false
650+
// result: 1
653651
//
654652
// [valkey.io]: https://valkey.io/commands/sort/
655-
SortStoreWithOptions(key string, destination string, sortOptions *options.SortOptions) (Result[int64], error)
653+
SortStoreWithOptions(key string, destination string, sortOptions *options.SortOptions) (int64, error)
656654

657655
// Sorts the elements in the list, set, or sorted set at key and returns the result.
658656
// The sortReadOnly command can be used to sort elements based on different criteria and apply

go/integTest/shared_commands_test.go

Lines changed: 11 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3776,18 +3776,11 @@ func (suite *GlideTestSuite) TestSortStore_BasicSorting() {
37763776

37773777
assert.Nil(suite.T(), err)
37783778
assert.NotNil(suite.T(), result)
3779-
assert.Equal(suite.T(), int64(5), result.Value())
3779+
assert.Equal(suite.T(), int64(5), result)
37803780

37813781
sortedValues, err := client.LRange(sortedKey, 0, -1)
3782-
resultList := []api.Result[string]{
3783-
api.CreateStringResult("1"),
3784-
api.CreateStringResult("2"),
3785-
api.CreateStringResult("4"),
3786-
api.CreateStringResult("5"),
3787-
api.CreateStringResult("10"),
3788-
}
37893782
assert.Nil(suite.T(), err)
3790-
assert.Equal(suite.T(), resultList, sortedValues)
3783+
assert.Equal(suite.T(), []string{"1", "2", "4", "5", "10"}, sortedValues)
37913784
})
37923785
}
37933786

@@ -3796,7 +3789,7 @@ func (suite *GlideTestSuite) TestSortStore_ErrorHandling() {
37963789
result, err := client.SortStore("{listKey}nonExistingKey", "{listKey}mydestinationKey")
37973790

37983791
assert.Nil(suite.T(), err)
3799-
assert.Equal(suite.T(), int64(0), result.Value())
3792+
assert.Equal(suite.T(), int64(0), result)
38003793
})
38013794
}
38023795

@@ -3811,18 +3804,11 @@ func (suite *GlideTestSuite) TestSortStoreWithOptions_DescendingOrder() {
38113804

38123805
assert.Nil(suite.T(), err)
38133806
assert.NotNil(suite.T(), result)
3814-
assert.Equal(suite.T(), int64(5), result.Value())
3807+
assert.Equal(suite.T(), int64(5), result)
38153808

38163809
sortedValues, err := client.LRange(sortedKey, 0, -1)
3817-
resultList := []api.Result[string]{
3818-
api.CreateStringResult("50"),
3819-
api.CreateStringResult("40"),
3820-
api.CreateStringResult("30"),
3821-
api.CreateStringResult("20"),
3822-
api.CreateStringResult("10"),
3823-
}
38243810
assert.Nil(suite.T(), err)
3825-
assert.Equal(suite.T(), resultList, sortedValues)
3811+
assert.Equal(suite.T(), []string{"50", "40", "30", "20", "10"}, sortedValues)
38263812
})
38273813
}
38283814

@@ -3837,16 +3823,10 @@ func (suite *GlideTestSuite) TestSortStoreWithOptions_AlphaSorting() {
38373823

38383824
assert.Nil(suite.T(), err)
38393825
assert.NotNil(suite.T(), result)
3840-
assert.Equal(suite.T(), int64(5), result.Value())
3826+
assert.Equal(suite.T(), int64(5), result)
38413827

38423828
sortedValues, err := client.LRange(sortedKey, 0, -1)
3843-
resultList := []api.Result[string]{
3844-
api.CreateStringResult("apple"),
3845-
api.CreateStringResult("banana"),
3846-
api.CreateStringResult("cherry"),
3847-
api.CreateStringResult("date"),
3848-
api.CreateStringResult("elderberry"),
3849-
}
3829+
resultList := []string{"apple", "banana", "cherry", "date", "elderberry"}
38503830
assert.Nil(suite.T(), err)
38513831
assert.Equal(suite.T(), resultList, sortedValues)
38523832
})
@@ -3863,16 +3843,11 @@ func (suite *GlideTestSuite) TestSortStoreWithOptions_Limit() {
38633843

38643844
assert.Nil(suite.T(), err)
38653845
assert.NotNil(suite.T(), result)
3866-
assert.Equal(suite.T(), int64(3), result.Value())
3846+
assert.Equal(suite.T(), int64(3), result)
38673847

38683848
sortedValues, err := client.LRange(sortedKey, 0, -1)
3869-
resultList := []api.Result[string]{
3870-
api.CreateStringResult("20"),
3871-
api.CreateStringResult("30"),
3872-
api.CreateStringResult("40"),
3873-
}
38743849
assert.Nil(suite.T(), err)
3875-
assert.Equal(suite.T(), resultList, sortedValues)
3850+
assert.Equal(suite.T(), []string{"20", "30", "40"}, sortedValues)
38763851
})
38773852
}
38783853

@@ -6513,17 +6488,10 @@ func (suite *GlideTestSuite) TestSortStoreWithOptions_ByPattern() {
65136488

65146489
assert.Nil(suite.T(), err)
65156490
assert.NotNil(suite.T(), result)
6516-
assert.Equal(suite.T(), int64(5), result.Value())
6491+
assert.Equal(suite.T(), int64(5), result)
65176492

65186493
sortedValues, err := client.LRange(sortedKey, 0, -1)
6519-
resultList := []api.Result[string]{
6520-
api.CreateStringResult("d"),
6521-
api.CreateStringResult("b"),
6522-
api.CreateStringResult("c"),
6523-
api.CreateStringResult("e"),
6524-
api.CreateStringResult("a"),
6525-
}
65266494
assert.Nil(suite.T(), err)
6527-
assert.Equal(suite.T(), resultList, sortedValues)
6495+
assert.Equal(suite.T(), []string{"d", "b", "c", "e", "a"}, sortedValues)
65286496
})
65296497
}

0 commit comments

Comments
 (0)