mirror of
https://github.com/redis/go-redis.git
synced 2025-04-16 09:23:06 +03:00
use limit when limitoffset is zero (#3275)
This commit is contained in:
parent
9db1286414
commit
196fc9b21a
@ -574,11 +574,8 @@ func FTAggregateQuery(query string, options *FTAggregateOptions) AggregateQuery
|
||||
if options.SortByMax > 0 {
|
||||
queryArgs = append(queryArgs, "MAX", options.SortByMax)
|
||||
}
|
||||
if options.LimitOffset > 0 {
|
||||
queryArgs = append(queryArgs, "LIMIT", options.LimitOffset)
|
||||
}
|
||||
if options.Limit > 0 {
|
||||
queryArgs = append(queryArgs, options.Limit)
|
||||
if options.LimitOffset >= 0 && options.Limit > 0 {
|
||||
queryArgs = append(queryArgs, "LIMIT", options.LimitOffset, options.Limit)
|
||||
}
|
||||
if options.Filter != "" {
|
||||
queryArgs = append(queryArgs, "FILTER", options.Filter)
|
||||
@ -773,11 +770,8 @@ func (c cmdable) FTAggregateWithArgs(ctx context.Context, index string, query st
|
||||
if options.SortByMax > 0 {
|
||||
args = append(args, "MAX", options.SortByMax)
|
||||
}
|
||||
if options.LimitOffset > 0 {
|
||||
args = append(args, "LIMIT", options.LimitOffset)
|
||||
}
|
||||
if options.Limit > 0 {
|
||||
args = append(args, options.Limit)
|
||||
if options.LimitOffset >= 0 && options.Limit > 0 {
|
||||
args = append(args, "LIMIT", options.LimitOffset, options.Limit)
|
||||
}
|
||||
if options.Filter != "" {
|
||||
args = append(args, "FILTER", options.Filter)
|
||||
|
@ -616,6 +616,11 @@ var _ = Describe("RediSearch commands Resp 2", Label("search"), func() {
|
||||
res, err = client.FTAggregateWithArgs(ctx, "idx1", "*", options).Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(res.Rows[0].Fields["t1"]).To(BeEquivalentTo("b"))
|
||||
|
||||
options = &redis.FTAggregateOptions{SortBy: []redis.FTAggregateSortBy{{FieldName: "@t1"}}, Limit: 1, LimitOffset: 0}
|
||||
res, err = client.FTAggregateWithArgs(ctx, "idx1", "*", options).Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(res.Rows[0].Fields["t1"]).To(BeEquivalentTo("a"))
|
||||
})
|
||||
|
||||
It("should FTAggregate load ", Label("search", "ftaggregate"), func() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user