Skip to content

Commit 6803031

Browse files
committed
fix Select
1 parent 8378a06 commit 6803031

3 files changed

Lines changed: 4 additions & 3 deletions

File tree

src/RESPite/Messages/RespReader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1771,7 +1771,7 @@ public readonly double ReadDouble()
17711771
/// <summary>
17721772
/// Try to read the current element as a <see cref="double"/> value.
17731773
/// </summary>
1774-
public bool TryReadDouble(out double value, bool allowTokens = true)
1774+
public readonly bool TryReadDouble(out double value, bool allowTokens = true)
17751775
{
17761776
var span = Buffer(stackalloc byte[RespConstants.MaxRawBytesNumber + 1]);
17771777

toys/StackExchange.Redis.Server/RedisServer.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,8 +1237,7 @@ protected virtual TypedRedisValue Role(RedisClient client, in RedisRequest reque
12371237
protected virtual TypedRedisValue Select(RedisClient client, in RedisRequest request)
12381238
{
12391239
var raw = request.GetValue(1);
1240-
if (!raw.IsInteger) return TypedRedisValue.Error("ERR invalid DB index");
1241-
int db = (int)raw;
1240+
if (!raw.TryParse(out int db)) return TypedRedisValue.Error("ERR invalid DB index");
12421241
if (db < 0 || db >= Databases) return TypedRedisValue.Error("ERR DB index is out of range");
12431242
client.Database = db;
12441243
return TypedRedisValue.OK;

toys/StackExchange.Redis.Server/RespReaderExtensions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ public RedisValue ReadRedisValue()
2020
{
2121
RespPrefix.Boolean => reader.ReadBoolean(),
2222
RespPrefix.Integer => reader.ReadInt64(),
23+
_ when reader.TryReadInt64(out var i64) => i64,
24+
_ when reader.TryReadDouble(out var fp64) => fp64,
2325
_ => reader.ReadByteArray(),
2426
};
2527
}

0 commit comments

Comments
 (0)