fix duplication of same objects in db with when saving a child scenario

This commit is contained in:
Dylan Jeannin committed 2026-05-19 16:13:21 +02:00
1 parent 348417977d
commit ccf3da114b
5 files changed
+17 -4

No files matched your search

+4 -2
View File
@@ -400,7 +400,7 @@ class Pollutants(SQLSubModel):
return new
table = execute(
"SELECT pamhyr_id, deleted, name FROM pollutants " +
"SELECT pamhyr_id, deleted, name, scenario FROM pollutants " +
f"WHERE scenario = {scenario.id} " +
f"AND pamhyr_id NOT IN ({', '.join(map(str, loaded))})"
)
@@ -412,10 +412,12 @@ class Pollutants(SQLSubModel):
pid = next(it)
deleted = (next(it) == 1)
name = next(it)
owner_scenario = next(it)
new_pollutant = cls(
id=pid, name=name,
status=status
status=status,
owner_scenario=owner_scenario
)
if deleted:
new_pollutant.set_as_deleted()