Skip to content

Commit

Permalink
Support tuple primary key (as the old impl does)
Browse files Browse the repository at this point in the history
Also, r_model is optional (same as the old impl)
  • Loading branch information
tyt2y3 committed Jul 7, 2023
1 parent 93dce5a commit 2f671ef
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/executor/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1044,9 +1044,8 @@ where
L: EntityTrait,
R: EntityTrait,
{
let mut hashmap: HashMap<KEY::Type, Vec<R::Model>> = rows.iter_mut().fold(
HashMap::<KEY::Type, Vec<R::Model>>::new(),
|mut acc: HashMap<KEY::Type, Vec<R::Model>>, row: &mut (L::Model, Option<R::Model>)| {
let mut hashmap: HashMap<KEY::Type, Vec<R::Model>> =
rows.iter_mut().fold(HashMap::new(), |mut acc, row| {
let key = model_key.get(&row.0);
if let Some(value) = row.1.take() {
let vec: Option<&mut Vec<R::Model>> = acc.get_mut(&key);
Expand All @@ -1058,8 +1057,7 @@ where
}

acc
},
);
});

rows.into_iter()
.filter_map(|(l_model, _)| {
Expand Down

0 comments on commit 2f671ef

Please sign in to comment.