Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Commit

Permalink
Fix another issue with the nested primary key selector
Browse files Browse the repository at this point in the history
  • Loading branch information
Kerollmops committed Jul 12, 2022
1 parent 192793e commit 25e768f
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions milli/src/update/index_documents/enrich.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ impl fmt::Debug for DocumentId {
}
}

fn contained_in(selector: &str, key: &str) -> bool {
fn starts_with(selector: &str, key: &str) -> bool {
selector.strip_prefix(key).map_or(false, |tail| {
tail.chars().next().map(|c| c == PRIMARY_KEY_SPLIT_SYMBOL).unwrap_or(true)
})
Expand All @@ -282,12 +282,7 @@ pub fn fetch_matching_values_in_object(
format!("{}{}{}", base_key, PRIMARY_KEY_SPLIT_SYMBOL, key)
};

// here if the user only specified `doggo` we need to iterate in all the fields of `doggo`
// so we check the contained_in on both side.
let should_continue =
contained_in(selector, &base_key) || contained_in(&base_key, selector);

if should_continue {
if starts_with(selector, &base_key) {
match value {
Value::Object(object) => {
fetch_matching_values_in_object(object, selector, &base_key, output)
Expand Down

0 comments on commit 25e768f

Please sign in to comment.