Skip to content

Commit

Permalink
Fix clippy lint
Browse files Browse the repository at this point in the history
  • Loading branch information
lcdr authored and Xiphoseer committed May 31, 2024
1 parent 2cb2be9 commit 475a4c8
Showing 1 changed file with 24 additions and 19 deletions.
43 changes: 24 additions & 19 deletions src/api/graphql.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::collections::HashMap;
use std::cmp::Ordering;
use std::fmt;
use std::fmt::Write;
use std::{borrow::Borrow, path::Path};
Expand Down Expand Up @@ -441,27 +442,31 @@ fn table_to_json_inner(

if let rusqlite::types::ValueRef::Integer(rowid) = rowid_col {
// since SQL joins duplicate values, we use the sorted rowid to deduplicate
if rowid > table_query.rowid {
// new row, read in data
if table_query.rowid > 0 {
// we read a row before, whose subbuffers need to be flushed out
let out = flush_table_data(table_query);
table_query.flushed_outputs.push(out);
match rowid.cmp(&table_query.rowid) {
Ordering::Greater => {
// new row, read in data
if table_query.rowid > 0 {
// we read a row before, whose subbuffers need to be flushed out
let out = flush_table_data(table_query);
table_query.flushed_outputs.push(out);
}
// keep track of this rowid for the next row'scheck
table_query.rowid = rowid;

for col in &mut table_query.cols {
col.value = Some(valueref_to_json(&row.get_ref(*icol)?)?);
*icol += 1;
}
}
// keep track of this rowid for the next row'scheck
table_query.rowid = rowid;

for col in &mut table_query.cols {
col.value = Some(valueref_to_json(&row.get_ref(*icol)?)?);
*icol += 1;
Ordering::Equal => {
// already encountered this entry in a previous join, skip this table but not subtables, which might have new subentries
*icol += table_query.cols.len();
}
Ordering::Less => {
// already encountered this entry in a previous join, skip this and all subtables
skip = true;
*icol += table_query.cols.len();
}
} else if rowid == table_query.rowid {
// already encountered this entry in a previous join, skip this table but not subtables, which might have new subentries
*icol += table_query.cols.len();
} else {
// already encountered this entry in a previous join, skip this and all subtables
skip = true;
*icol += table_query.cols.len();
}
} else {
// left join is null, skip
Expand Down

0 comments on commit 475a4c8

Please sign in to comment.