1
0
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:
Pragalva
2026-10-19 17:15:36 +05:45
committed by GitHub
parent 9bb5c7c2c6
commit 5fcaf27e1a
2 changed files with 12 additions and 2 deletions

View File

@@ -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.

View File

@@ -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")
}
}