diff --git a/editoast/editoast_derive/src/modelv2/codegen/create_batch_impl.rs b/editoast/editoast_derive/src/modelv2/codegen/create_batch_impl.rs index ca4c52abba5..4ba0bf8ef2c 100644 --- a/editoast/editoast_derive/src/modelv2/codegen/create_batch_impl.rs +++ b/editoast/editoast_derive/src/modelv2/codegen/create_batch_impl.rs @@ -39,6 +39,7 @@ impl ToTokens for CreateBatchImpl { use diesel::prelude::*; use diesel_async::RunQueryDsl; use futures_util::stream::TryStreamExt; + let values = values.into_iter().collect::>(); Ok(crate::chunked_for_libpq! { #field_count, values, diff --git a/editoast/src/modelsv2/prelude/mod.rs b/editoast/src/modelsv2/prelude/mod.rs index e47eb2a1d28..2bd9c8cfdc9 100644 --- a/editoast/src/modelsv2/prelude/mod.rs +++ b/editoast/src/modelsv2/prelude/mod.rs @@ -128,9 +128,8 @@ macro_rules! chunked_for_libpq { const ASYNC_SUBDIVISION: usize = 2_usize; const CHUNK_SIZE: usize = LIBPQ_MAX_PARAMETERS / ASYNC_SUBDIVISION / $parameters_per_row; let mut result = Vec::new(); - let values = $values.into_iter().collect::>(); - let chunks = values.chunks(CHUNK_SIZE); - for $chunk in chunks.into_iter() { + let chunks = $values.chunks(CHUNK_SIZE); + for $chunk in chunks { let chunk_result = $query; result.push(chunk_result); } @@ -143,9 +142,8 @@ macro_rules! chunked_for_libpq { const ASYNC_SUBDIVISION: usize = 2_usize; const CHUNK_SIZE: usize = LIBPQ_MAX_PARAMETERS / ASYNC_SUBDIVISION / $parameters_per_row; let mut result = $result; - let values = $values.into_iter().collect::>(); - let chunks = values.chunks(CHUNK_SIZE); - for $chunk in chunks.into_iter() { + let chunks = $values.chunks(CHUNK_SIZE); + for $chunk in chunks { let chunk_result = $query; result.extend(chunk_result); }