Skip to content

Commit

Permalink
Issue StackExchange#111: HashSet with RedisValue.EmptyString do not w…
Browse files Browse the repository at this point in the history
…ork as ""

Simple reorder of static field init order fixes this issue.
  • Loading branch information
luberg committed Dec 7, 2014
1 parent d994b7a commit 1a4903b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
17 changes: 13 additions & 4 deletions MigratedBookSleeveTestSuite/Hashes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,17 +178,26 @@ public void TestSet() // http://redis.io/commands/hset
var val2 = conn.HashGetAsync("hashkey", "field");

var set2 = conn.HashSetAsync("hashkey", "field-blob", Encoding.UTF8.GetBytes("value3"));
var val3 = conn.HashGetAsync("hashkey", "field-blob");

var val3 = conn.HashGetAsync("hashkey", "field-blob");

var set3 = conn.HashSetAsync("hashkey", "empty_type1", "");
var val4 = conn.HashGetAsync("hashkey", "empty_type1");
var set4 = conn.HashSetAsync("hashkey", "empty_type2", RedisValue.EmptyString);
var val5 = conn.HashGetAsync("hashkey", "empty_type2");

Assert.AreEqual(null, (string)val0.Result);
Assert.AreEqual(true, set0.Result);
Assert.AreEqual("value1", (string)val1.Result);
Assert.AreEqual(false, set1.Result);
Assert.AreEqual("value2", (string)val2.Result);

Assert.AreEqual(true, set2.Result);
Assert.AreEqual("value3", (string)val3.Result);

Assert.AreEqual("value3", (string)val3.Result);

Assert.AreEqual(true, set3.Result);
Assert.AreEqual("", (string)val4.Result);
Assert.AreEqual(true, set4.Result);
Assert.AreEqual("", (string)val5.Result);
}
}
[Test]
Expand Down
6 changes: 3 additions & 3 deletions StackExchange.Redis/StackExchange/Redis/RedisValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ namespace StackExchange.Redis
/// </summary>
public struct RedisValue : IEquatable<RedisValue>, IComparable<RedisValue>, IComparable, IConvertible
{
internal static readonly RedisValue[] EmptyArray = new RedisValue[0];
internal static readonly RedisValue[] EmptyArray = new RedisValue[0];

static readonly byte[] EmptyByteArr = new byte[0];

private static readonly RedisValue
@null = new RedisValue(0, null),
emptyString = new RedisValue(0, EmptyByteArr);

static readonly byte[] EmptyByteArr = new byte[0];

private static readonly byte[] IntegerSentinel = new byte[0];

private readonly byte[] valueBlob;
Expand Down

0 comments on commit 1a4903b

Please sign in to comment.