mirror of
https://github.com/redis/go-redis.git
synced 2026-10-22 19:49:00 +03:00
fix(search): initialize options in NewDropIndexBuilder to prevent panic (#4105)
Signed-off-by: Pragalva Sapkota <sapkotapragalva@gmail.com>
This commit is contained in:
@@ -562,10 +562,10 @@ type DropIndexBuilder struct {
|
||||
// NewDropIndexBuilder creates a new DropIndexBuilder for FT.DROPINDEX commands.
|
||||
// EXPERIMENTAL: this API is subject to change, use with caution.
|
||||
func (c *Client) NewDropIndexBuilder(ctx context.Context, index string) *DropIndexBuilder {
|
||||
return &DropIndexBuilder{c: c, ctx: ctx, index: index}
|
||||
return &DropIndexBuilder{c: c, ctx: ctx, index: index, options: &FTDropIndexOptions{}}
|
||||
}
|
||||
|
||||
// DeleteRuncs includes DD.
|
||||
// DeleteDocs includes DD.
|
||||
func (b *DropIndexBuilder) DeleteDocs() *DropIndexBuilder { b.options.DeleteDocs = true; return b }
|
||||
|
||||
// Run executes FT.DROPINDEX.
|
||||
|
||||
@@ -698,3 +698,13 @@ func TestParseFTHybridWarnings(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestDropIndexBuilderDeleteDocs(t *testing.T) {
|
||||
client := NewClient(&Options{Addr: "localhost:6379"})
|
||||
defer client.Close()
|
||||
|
||||
builder := client.NewDropIndexBuilder(context.Background(), "idx").DeleteDocs()
|
||||
if builder.options == nil || !builder.options.DeleteDocs {
|
||||
t.Fatal("expected DeleteDocs to be true")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user