Skip to content

Commit

Permalink
Merge branch 'valkey-io:main' into Go-Implement-Dump-ObjectEncoding-c…
Browse files Browse the repository at this point in the history
…ommand
  • Loading branch information
EdricCua authored Jan 10, 2025
2 parents c9ed87f + 4334c54 commit d0c67c3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@

#### Fixes

* Node: Fix `zrangeWithScores` (disallow `RangeByLex` as it is not supported) ([#2926](https://github.com/valkey-io/valkey-glide/pull/2926))
* 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
3 changes: 1 addition & 2 deletions node/src/BaseClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4443,7 +4443,6 @@ export class BaseClient {
* @param key - The key of the sorted set.
* @param rangeQuery - The range query object representing the type of range query to perform.
* - For range queries by index (rank), use {@link RangeByIndex}.
* - For range queries by lexicographical order, use {@link RangeByLex}.
* - For range queries by score, use {@link RangeByScore}.
* @param options - (Optional) Additional parameters:
* - (Optional) `reverse`: if `true`, reverses the sorted set, with index `0` as the element with the highest score.
Expand Down Expand Up @@ -4476,7 +4475,7 @@ export class BaseClient {
*/
public async zrangeWithScores(
key: GlideString,
rangeQuery: RangeByScore | RangeByLex | RangeByIndex,
rangeQuery: RangeByScore | RangeByIndex,
options?: { reverse?: boolean } & DecoderOption,
): Promise<SortedSetDataType> {
return this.createWritePromise<GlideRecord<number>>(
Expand Down
3 changes: 1 addition & 2 deletions node/src/Transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1989,7 +1989,6 @@ export class BaseTransaction<T extends BaseTransaction<T>> {
* @param key - The key of the sorted set.
* @param rangeQuery - The range query object representing the type of range query to perform.
* - For range queries by index (rank), use {@link RangeByIndex}.
* - For range queries by lexicographical order, use {@link RangeByLex}.
* - For range queries by score, use {@link RangeByScore}.
* @param reverse - If `true`, reverses the sorted set, with index `0` as the element with the highest score.
*
Expand All @@ -1999,7 +1998,7 @@ export class BaseTransaction<T extends BaseTransaction<T>> {
*/
public zrangeWithScores(
key: GlideString,
rangeQuery: RangeByScore | RangeByLex | RangeByIndex,
rangeQuery: RangeByScore | RangeByIndex,
reverse = false,
): T {
return this.addAndReturn(
Expand Down

0 comments on commit d0c67c3

Please sign in to comment.