| 1214 | /// This is the legacy consolidate algorithm. Kept for reference |
| 1215 | #[allow(dead_code)] |
| 1216 | fn consolidate_query_result_of_ordered_rows<L, R>( |
| 1217 | rows: Vec<(L::Model, Option<R::Model>)>, |
| 1218 | ) -> Vec<(L::Model, Vec<R::Model>)> |
| 1219 | where |
| 1220 | L: EntityTrait, |
| 1221 | R: EntityTrait, |
| 1222 | { |
| 1223 | let mut acc: Vec<(L::Model, Vec<R::Model>)> = Vec::new(); |
| 1224 | for (l, r) in rows { |
| 1225 | if let Some((last_l, last_r)) = acc.last_mut() { |
| 1226 | let mut same_l = true; |
| 1227 | for pk_col in <L::PrimaryKey as Iterable>::iter() { |
| 1228 | let col = pk_col.into_column(); |
| 1229 | let val = l.get(col); |
| 1230 | let last_val = last_l.get(col); |
| 1231 | if !val.eq(&last_val) { |
| 1232 | same_l = false; |
| 1233 | break; |
| 1234 | } |
| 1235 | } |
| 1236 | if same_l { |
| 1237 | if let Some(r) = r { |
| 1238 | last_r.push(r); |
| 1239 | continue; |
| 1240 | } |
| 1241 | } |
| 1242 | } |
| 1243 | let rows = match r { |
| 1244 | Some(r) => vec![r], |
| 1245 | None => vec![], |
| 1246 | }; |
| 1247 | acc.push((l, rows)); |
| 1248 | } |
| 1249 | acc |
| 1250 | } |
| 1251 | |
| 1252 | #[cfg(test)] |
| 1253 | mod tests { |