From b48e221936a688bd1a1a5b1e3f2f08e43d0fe65a Mon Sep 17 00:00:00 2001 From: Keuin Date: Sat, 24 Feb 2024 03:27:28 +0800 Subject: bugfix: non-distinct fields are ignored in result --- src/main.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index 3cb93db..220c69e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -245,10 +245,17 @@ async fn query( } }; for (field, value) in result { + if let Some(set) = all_result.get_mut(&field) { + set.insert(value.clone()); + } else { + let mut s = HashSet::new(); + s.insert(value.clone()); + all_result.insert(field.clone(), s); + } let v = RelationFieldValue { relation: rel.cfg.name.clone(), field: field.clone(), - value: value.clone(), + value, }; // skip non-distinct fields to prevent generating irrelevant results if !state.fields.get(&field).expect("missing field info").distinct { @@ -259,13 +266,6 @@ async fn query( continue; } unvisited.insert(v); - if let Some(set) = all_result.get_mut(&field) { - set.insert(value); - } else { - let mut s = HashSet::new(); - s.insert(value); - all_result.insert(field, s); - } } unvisited.remove(&RelationFieldValue { relation: rel.cfg.name.clone(), -- cgit v1.2.3