Rewrite multi loader query use
This commit is contained in:
parent
1d0ab456b9
commit
9c1b13bfb7
@ -236,7 +236,7 @@ impl FindProducts {
|
|||||||
self,
|
self,
|
||||||
pool: &mut sqlx::Transaction<'_, sqlx::Postgres>,
|
pool: &mut sqlx::Transaction<'_, sqlx::Postgres>,
|
||||||
) -> Result<Vec<Product>> {
|
) -> Result<Vec<Product>> {
|
||||||
db_utils::MultiLoad::new(
|
let mut loader = db_utils::MultiLoad::new(
|
||||||
pool,
|
pool,
|
||||||
r#"
|
r#"
|
||||||
SELECT id,
|
SELECT id,
|
||||||
@ -248,7 +248,8 @@ WHERE
|
|||||||
"#,
|
"#,
|
||||||
"products.id =",
|
"products.id =",
|
||||||
)
|
)
|
||||||
.with_size(200)
|
.with_size(200);
|
||||||
|
loader
|
||||||
.load(
|
.load(
|
||||||
self.product_ids.len(),
|
self.product_ids.len(),
|
||||||
self.product_ids.into_iter().map(|id| *id),
|
self.product_ids.into_iter().map(|id| *id),
|
||||||
@ -372,10 +373,7 @@ mod tests {
|
|||||||
Product {
|
Product {
|
||||||
id: original.id,
|
id: original.id,
|
||||||
name: ProductName::new("a9s0dja0sjd0jas09dj"),
|
name: ProductName::new("a9s0dja0sjd0jas09dj"),
|
||||||
short_description: ProductShortDesc::new("ajs9d8ua9sdu9ahsd98has"),
|
|
||||||
long_description: ProductLongDesc::new("hja89sdy9yha9sdy98ayusd9hya9sy8dh"),
|
|
||||||
category: None,
|
category: None,
|
||||||
price: Price::from_u32(823794),
|
|
||||||
deliver_days_flag: Day::Tuesday | Day::Saturday,
|
deliver_days_flag: Day::Tuesday | Day::Saturday,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user