mirror of https://gitlab.com/pamhyr/pamhyr2
Frictions: Fix none assiciated stricklers at save/load.
parent
e86111bd7a
commit
8b8aff7df1
|
|
@ -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):
|
||||||
|
|
||||||
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):
|
||||||
"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}" +
|
||||||
")"
|
")"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue