Skip to content

Commit 0c25f99

Browse files
committed
editoast: add error_layers when cloning an infra
1 parent 8ecea1c commit 0c25f99

File tree

1 file changed

+10
-2
lines changed
  • editoast/src/views/infra

1 file changed

+10
-2
lines changed

editoast/src/views/infra/mod.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ async fn clone(
290290
for object in ObjectType::iter() {
291291
let model_table = object.get_table();
292292
let model = sql_query(format!(
293-
"INSERT INTO {model_table}(obj_id,data,infra_id) SELECT obj_id,data,$1 FROM {model_table} WHERE infra_id=$2"
293+
"INSERT INTO {model_table}(obj_id,data,infra_id) SELECT obj_id,data,$1 FROM {model_table} WHERE infra_id = $2"
294294
))
295295
.bind::<BigInt, _>(cloned_infra.id.unwrap())
296296
.bind::<BigInt, _>(infra)
@@ -304,7 +304,7 @@ async fn clone(
304304
"INSERT INTO {layer_table}(obj_id,geographic,schematic,infra_id) SELECT obj_id,geographic,schematic,$1 FROM {layer_table} WHERE infra_id=$2")
305305
} else {
306306
format!(
307-
"INSERT INTO {layer_table}(obj_id,geographic,schematic,infra_id, angle_geo, angle_sch) SELECT obj_id,geographic,schematic,$1,angle_geo,angle_sch FROM {layer_table} WHERE infra_id=$2"
307+
"INSERT INTO {layer_table}(obj_id,geographic,schematic,infra_id, angle_geo, angle_sch) SELECT obj_id,geographic,schematic,$1,angle_geo,angle_sch FROM {layer_table} WHERE infra_id = $2"
308308
)
309309
};
310310

@@ -316,7 +316,15 @@ async fn clone(
316316
}
317317
}
318318

319+
// Add error layers
320+
let error_layer = sql_query("INSERT INTO infra_layer_error(geographic, schematic, information, infra_id) SELECT geographic, schematic, information, $1 FROM infra_layer_error WHERE infra_id = $2")
321+
.bind::<BigInt, _>(cloned_infra.id.unwrap())
322+
.bind::<BigInt, _>(infra)
323+
.execute(&mut conn);
324+
futures.push(error_layer);
325+
319326
let _res = try_join_all(futures).await?;
327+
320328
Ok(Json(cloned_infra.id.unwrap()))
321329
}
322330

0 commit comments

Comments
 (0)