From 7de907e744349d67b1916450f6c27a4cb74382ea Mon Sep 17 00:00:00 2001 From: Martijn Visser Date: Mon, 25 Mar 2024 14:09:25 +0100 Subject: [PATCH] Error early on non globally unique node IDs Alleviates https://github.com/Deltares/Ribasim/issues/1262 --- core/src/model.jl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/src/model.jl b/core/src/model.jl index 009cd80c2..afa24347e 100644 --- a/core/src/model.jl +++ b/core/src/model.jl @@ -85,6 +85,13 @@ function Model(config::Config)::Model state = load_structvector(db, config, BasinStateV1) n = length(get_ids(db, "Basin")) + sql = "SELECT node_id FROM Node ORDER BY node_id" + node_id = only(execute(columntable, db, sql)) + if !allunique(node_id) + error( + "Node IDs need to be globally unique until https://github.com/Deltares/Ribasim/issues/1262 is fixed.", + ) + end finally # always close the database, also in case of an error close(db)