From 83b8c0a9c04292433a8fafe784958a28939a5073 Mon Sep 17 00:00:00 2001 From: Vladimir Mihailenco Date: Tue, 1 Dec 2015 16:28:41 +0200 Subject: [PATCH] Fix ZStore Weight type. Fixes #206. --- commands.go | 12 ++++-------- commands_test.go | 4 ++-- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/commands.go b/commands.go index 2a7f7922..d3e27428 100644 --- a/commands.go +++ b/commands.go @@ -990,15 +990,15 @@ func (c *commandable) SUnionStore(destination string, keys ...string) *IntCmd { //------------------------------------------------------------------------------ -// Sorted set member. +// Z represents sorted set member. type Z struct { Score float64 Member interface{} } -// Sorted set store operation. +// ZStore is used as an arg to ZInterStore and ZUnionStore. type ZStore struct { - Weights []int64 + Weights []float64 // Can be SUM, MIN or MAX. Aggregate string } @@ -1113,11 +1113,7 @@ func (c *commandable) ZIncrBy(key string, increment float64, member string) *Flo return cmd } -func (c *commandable) ZInterStore( - destination string, - store ZStore, - keys ...string, -) *IntCmd { +func (c *commandable) ZInterStore(destination string, store ZStore, keys ...string) *IntCmd { args := make([]interface{}, 3+len(keys)) args[0] = "ZINTERSTORE" args[1] = destination diff --git a/commands_test.go b/commands_test.go index 4e3488dd..327cc264 100644 --- a/commands_test.go +++ b/commands_test.go @@ -2082,7 +2082,7 @@ var _ = Describe("Commands", func() { Expect(zAdd.Err()).NotTo(HaveOccurred()) zInterStore := client.ZInterStore( - "out", redis.ZStore{Weights: []int64{2, 3}}, "zset1", "zset2") + "out", redis.ZStore{Weights: []float64{2, 3}}, "zset1", "zset2") Expect(zInterStore.Err()).NotTo(HaveOccurred()) Expect(zInterStore.Val()).To(Equal(int64(2))) @@ -2479,7 +2479,7 @@ var _ = Describe("Commands", func() { Expect(zAdd.Err()).NotTo(HaveOccurred()) zUnionStore := client.ZUnionStore( - "out", redis.ZStore{Weights: []int64{2, 3}}, "zset1", "zset2") + "out", redis.ZStore{Weights: []float64{2, 3}}, "zset1", "zset2") Expect(zUnionStore.Err()).NotTo(HaveOccurred()) Expect(zUnionStore.Val()).To(Equal(int64(3)))