mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
AdisTS: OutputRK, IC, LC: Add deleted tag in DB.
This commit is contained in:
1 parent
0ed7660e72
commit
ba60585550
7 files changed
+50
-26
No files matched your search
@@ -77,17 +77,18 @@ class OutputRKAdists(SQLSubModel):
|
||||
|
||||
@classmethod
|
||||
def _db_create(cls, execute, ext=""):
|
||||
execute(
|
||||
f"CREATE TABLE output_rk_adists{ext}(" +
|
||||
f"{cls.create_db_add_pamhyr_id()},"
|
||||
"reach INTEGER NOT NULL, " +
|
||||
"rk REAL NOT NULL, " +
|
||||
"title TEXT NOT NULL, " +
|
||||
f"{Scenario.create_db_add_scenario()},"
|
||||
f"{Scenario.create_db_add_scenario_fk()},"
|
||||
"FOREIGN KEY(reach) REFERENCES river_reach(id)" +
|
||||
")"
|
||||
)
|
||||
execute(f"""
|
||||
CREATE TABLE output_rk_adists{ext}(
|
||||
{cls.create_db_add_pamhyr_id()},
|
||||
deleted BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
reach INTEGER NOT NULL,
|
||||
rk REAL NOT NULL,
|
||||
title TEXT NOT NULL,
|
||||
{Scenario.create_db_add_scenario()},
|
||||
{Scenario.create_db_add_scenario_fk()},
|
||||
FOREIGN KEY(reach) REFERENCES river_reach(id)
|
||||
)
|
||||
""")
|
||||
|
||||
return cls._create_submodel(execute)
|
||||
|
||||
@@ -144,7 +145,7 @@ class OutputRKAdists(SQLSubModel):
|
||||
return new
|
||||
|
||||
table = execute(
|
||||
"SELECT pamhyr_id, reach, rk, title, scenario " +
|
||||
"SELECT pamhyr_id, deleted, reach, rk, title, scenario " +
|
||||
f"FROM output_rk_adists"
|
||||
)
|
||||
|
||||
@@ -153,6 +154,7 @@ class OutputRKAdists(SQLSubModel):
|
||||
it = iter(row)
|
||||
|
||||
pid = next(it)
|
||||
deleted = (next(it) == 1)
|
||||
id_reach = next(it)
|
||||
id_rk = next(it)
|
||||
title = next(it)
|
||||
@@ -164,6 +166,8 @@ class OutputRKAdists(SQLSubModel):
|
||||
status=status,
|
||||
owner_scenario=owner_scenario,
|
||||
)
|
||||
if deleted:
|
||||
new_output.set_as_deleted()
|
||||
|
||||
loaded.add(pid)
|
||||
new.append(new_output)
|
||||
@@ -186,9 +190,11 @@ class OutputRKAdists(SQLSubModel):
|
||||
|
||||
execute(
|
||||
"INSERT INTO " +
|
||||
"output_rk_adists(pamhyr_id, reach, rk, title, scenario) " +
|
||||
"output_rk_adists(pamhyr_id, deleted, " +
|
||||
"reach, rk, title, scenario) " +
|
||||
"VALUES (" +
|
||||
f"{self.id}, {self._reach}, {self._rk}, " +
|
||||
f"{self.id}, {self._db_format({self.is_deleted()})}" +
|
||||
f"{self._reach}, {self._rk}, " +
|
||||
f"'{self._db_format(self._title)}'" +
|
||||
f"{self._status.scenario_id}" +
|
||||
")"
|
||||
|
||||
Reference in new issue
Block a user