Skip to content

Commit

Permalink
Fix value conversion for CONFIG GET. (#2381) (#2929)
Browse files Browse the repository at this point in the history
* Fix value conversion for `CONFIG GET`. (#2381)

Signed-off-by: Yury-Fridlyand <[email protected]>
  • Loading branch information
Yury-Fridlyand authored Jan 9, 2025
1 parent e776aa1 commit 862cba9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 7 additions & 3 deletions glide-core/src/client/value_conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ExpectedReturnType<'a>>,
Option<fn(Value) -> bool>,
Option<&'a (dyn Fn(Value) -> bool + Sync)>,
),
MapOfStringToDouble,
Double,
Expand Down Expand Up @@ -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<ExpectedReturnType> {
let command = cmd.command()?;

Expand All @@ -1403,7 +1407,7 @@ pub(crate) fn expected_type_for_cmd(cmd: &Cmd) -> Option<ExpectedReturnType> {
key_type: &None,
value_type: &None,
}),
Some(|val| matches!(val, Value::Array(_))),
Some(&is_array),
)),
b"XCLAIM" => {
if cmd.position(b"JUSTID").is_some() {
Expand Down Expand Up @@ -1497,7 +1501,7 @@ pub(crate) fn expected_type_for_cmd(cmd: &Cmd) -> Option<ExpectedReturnType> {
))),
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()
Expand Down

0 comments on commit 862cba9

Please sign in to comment.