mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
fix duplication of same objects in db with when saving a child scenario
This commit is contained in:
1 parent
348417977d
commit
ccf3da114b
5 files changed
+17
-4
No files matched your search
@@ -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()
|
||||
|
||||
Reference in new issue
Block a user