Commit 8b8aff7d authored by Pierre-Antoine Rouby's avatar Pierre-Antoine Rouby
Browse files

Frictions: Fix none assiciated stricklers at save/load.

Showing with 19 additions and 3 deletions
+19 -3
...@@ -77,8 +77,15 @@ class Friction(SQLSubModel): ...@@ -77,8 +77,15 @@ class Friction(SQLSubModel):
for row in table: for row in table:
ind = row[0] ind = row[0]
# Get stricklers # Get stricklers
bs = next(filter(lambda s: s.id == row[3], stricklers)) if int(row[3]) == -1:
es = next(filter(lambda s: s.id == row[4], stricklers)) bs = None
else:
bs = next(filter(lambda s: s.id == row[3], stricklers))
if int(row[4]) == -1:
es = None
else:
es = next(filter(lambda s: s.id == row[4], stricklers))
# Create friction # Create friction
sec = cls(status=status) sec = cls(status=status)
...@@ -94,6 +101,15 @@ class Friction(SQLSubModel): ...@@ -94,6 +101,15 @@ class Friction(SQLSubModel):
def _db_save(self, execute, data=None): def _db_save(self, execute, data=None):
ind = data["ind"] ind = data["ind"]
b_s_id = -1
e_s_id = -1
if self._begin_strickler is not None:
b_s_id = self._begin_strickler.id
if self._end_strickler is not None:
e_s_id = self._end_strickler.id
execute( execute(
"INSERT INTO " + "INSERT INTO " +
"friction(ind, begin_kp, end_kp, " + "friction(ind, begin_kp, end_kp, " +
...@@ -101,7 +117,7 @@ class Friction(SQLSubModel): ...@@ -101,7 +117,7 @@ class Friction(SQLSubModel):
"VALUES (" + "VALUES (" +
f"{ind}, {self._begin_kp}, {self._end_kp}, " + f"{ind}, {self._begin_kp}, {self._end_kp}, " +
f"{self._edge.id}, " + f"{self._edge.id}, " +
f"{self._begin_strickler.id}, {self._end_strickler.id}" + f"{b_s_id}, {e_s_id}" +
")" ")"
) )
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment