From 862cba95b0fea0e3cdb0cdb52041753f3ef109bb Mon Sep 17 00:00:00 2001 From: Yury-Fridlyand Date: Thu, 9 Jan 2025 10:01:41 -0800 Subject: [PATCH] Fix value conversion for `CONFIG GET`. (#2381) (#2929) * Fix value conversion for `CONFIG GET`. (#2381) Signed-off-by: Yury-Fridlyand --- CHANGELOG.md | 2 ++ glide-core/src/client/value_conversion.rs | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c724e6c52..75da3edd3a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,8 @@ #### Fixes +* Core: improve fix in #2381 ([#2929](https://github.com/valkey-io/valkey-glide/pull/2929)) + #### Operational Enhancements ## 1.2.1 (2024-12-29) diff --git a/glide-core/src/client/value_conversion.rs b/glide-core/src/client/value_conversion.rs index 7eafe3f373..2fcc94a4a7 100644 --- a/glide-core/src/client/value_conversion.rs +++ b/glide-core/src/client/value_conversion.rs @@ -13,7 +13,7 @@ pub(crate) enum ExpectedReturnType<'a> { // Second parameter is a function which returns true if value needs to be converted SingleOrMultiNode( &'a Option>, - Option bool>, + Option<&'a (dyn Fn(Value) -> bool + Sync)>, ), MapOfStringToDouble, Double, @@ -1387,6 +1387,10 @@ fn convert_flat_array_to_array_of_pairs( Ok(Value::Array(result)) } +fn is_array(val: Value) -> bool { + matches!(val, Value::Array(_)) +} + pub(crate) fn expected_type_for_cmd(cmd: &Cmd) -> Option { let command = cmd.command()?; @@ -1403,7 +1407,7 @@ pub(crate) fn expected_type_for_cmd(cmd: &Cmd) -> Option { key_type: &None, value_type: &None, }), - Some(|val| matches!(val, Value::Array(_))), + Some(&is_array), )), b"XCLAIM" => { if cmd.position(b"JUSTID").is_some() { @@ -1497,7 +1501,7 @@ pub(crate) fn expected_type_for_cmd(cmd: &Cmd) -> Option { ))), b"FUNCTION STATS" => Some(ExpectedReturnType::SingleOrMultiNode( &Some(ExpectedReturnType::FunctionStatsReturnType), - Some(|val| matches!(val, Value::Array(_))), + Some(&is_array), )), b"GEOSEARCH" => { if cmd.position(b"WITHDIST").is_some()