Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix value conversion for CONFIG GET. (#2381) #2929

Merged
merged 5 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
8 changes: 5 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,8 @@ fn convert_flat_array_to_array_of_pairs(
Ok(Value::Array(result))
}

const IS_ARRAY: &'static (dyn Fn(Value) -> bool + Sync) = &|val| matches!(val, Value::Array(_));
Yury-Fridlyand marked this conversation as resolved.
Show resolved Hide resolved

pub(crate) fn expected_type_for_cmd(cmd: &Cmd) -> Option<ExpectedReturnType> {
let command = cmd.command()?;

Expand All @@ -1403,7 +1405,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 +1499,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
Loading