Skip to content

Commit b1ed641

Browse files
committed
Fix redis query in search_by_index_prefix.
1 parent b16cb8a commit b1ed641

2 files changed

Lines changed: 20 additions & 10 deletions

File tree

nativelink-scheduler/tests/redis_store_awaited_action_db_test.rs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -216,19 +216,26 @@ impl Mocks for FakeRedisBackend {
216216
}
217217

218218
if actual.cmd == Str::from_static("FT.AGGREGATE") {
219-
// The query is @field:value where value might be wrapped in braces.
219+
// The query is @field:value where value might be wrapped in braces or *.
220220
let query = actual.args[1]
221221
.clone()
222222
.into_string()
223223
.expect("Aggregate query should be a string");
224-
assert_eq!(&query[..1], "@");
225-
let mut parts = query[1..].split(':');
226-
let field = parts.next().expect("No field name");
227-
let value = parts.next().expect("No value");
228-
let value = value
229-
.strip_prefix("{ ")
230-
.and_then(|s| s.strip_suffix(" }"))
231-
.unwrap_or(value);
224+
225+
let (field, value) = if query.as_str() == "*" {
226+
("", query.as_str())
227+
} else {
228+
assert_eq!(&query[..1], "@");
229+
let mut parts = query[1..].split(':');
230+
let field = parts.next().expect("No field name");
231+
let value = parts.next().expect("No value");
232+
let value = value
233+
.strip_prefix("{ ")
234+
.and_then(|s| s.strip_suffix(" }"))
235+
.unwrap_or(value);
236+
237+
(field, value)
238+
};
232239
// Lazy implementation making assumptions.
233240
assert_eq!(
234241
actual.args[2..6],

nativelink-store/src/redis_store.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1168,7 +1168,10 @@ impl SchedulerStore for RedisStore {
11681168
"{}",
11691169
get_index_name!(K::KEY_PREFIX, K::INDEX_NAME, K::MAYBE_SORT_KEY)
11701170
),
1171-
format!("@{}:{{ {} }}", K::INDEX_NAME, sanitized_field),
1171+
match sanitized_field.is_empty() {
1172+
true => String::from("*"),
1173+
false => format!("@{}:{{ {} }}", K::INDEX_NAME, sanitized_field),
1174+
},
11721175
FtAggregateOptions {
11731176
load: Some(Load::Some(vec![
11741177
SearchField {

0 commit comments

Comments
 (0)