修改用户分页查询bug
All checks were successful
build / build-rust (push) Successful in 1m57s

This commit is contained in:
soul-walker 2024-09-26 09:58:59 +08:00
parent f70e08e5e8
commit 18207bee18

View File

@ -77,9 +77,10 @@ impl UserPageFilter {
));
}
if clauses.is_empty() {
return "".to_string();
"".to_string()
} else {
format!("WHERE {}", clauses.join(" AND "))
}
clauses.join(" AND ")
}
}
@ -370,11 +371,27 @@ mod tests {
];
accessor.sync_user(users.as_slice()).await?;
// 分页查询检查是否更新成功
let page_result = accessor.query_user_page(page, filter.clone()).await?;
let page_result = accessor
.query_user_page(page.clone(), filter.clone())
.await?;
assert_eq!(page_result.total, 3);
assert_eq!(page_result.data.len(), 3);
println!("{:?}", page_result);
// 带过滤条件的分页查询
let filter = UserPageFilter {
id: Some(1),
name: None,
email: None,
mobile: None,
roles: None,
};
let page_result = accessor
.query_user_page(page.clone(), filter.clone())
.await?;
assert_eq!(page_result.total, 1);
assert_eq!(page_result.data.len(), 1);
Ok(())
}
}