You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let cloned_infra = Infra::clone(infra, db_pool_ref.clone(), name).await?;
280
-
278
+
let cloned_infra = Infra::clone(infra, db_pool.clone(), name).await?;
279
+
// When creating a connection for each objet, it will a panic with 'Cannot access shared transaction state' in bb8 database pool
280
+
// Just one connection fixes it, but partially* defeats the purpose of joining all the requests at the end
281
+
// * AsyncPgConnection supports pipeling within one connection, but it won’t run parallel
282
+
letmut conn = db_pool.get().await?;
281
283
for object inObjectType::iter(){
282
284
let model_table = object.get_table();
283
-
let db_pool_ref = db_pool.clone();
284
-
letmut conn = db_pool_ref.get().await?;
285
285
let model = sql_query(format!(
286
286
"INSERT INTO {model_table}(id, obj_id,data,infra_id) SELECT nextval('{model_table}_id_seq'), obj_id,data,$1 FROM {model_table} WHERE infra_id=$2"
287
287
))
@@ -300,8 +300,7 @@ async fn clone(
300
300
"INSERT INTO {layer_table}(id, obj_id,geographic,schematic,infra_id, angle_geo, angle_sch) SELECT nextval('{layer_table}_id_seq'), obj_id,geographic,schematic,$1,angle_geo,angle_sch FROM {layer_table} WHERE infra_id=$2"
0 commit comments