mirror of
https://github.com/wger-project/flutter.git
synced 2026-11-29 01:18:35 +01:00
fix: make routineId nullable in WorkoutLogTable to prevent crash
Server allows workout logs without a routine (free/ad-hoc logging), but the app's Drift table declared routineId as non-nullable. This caused a null check operator crash when PowerSync delivered a row with routine_id = NULL. Changes: - WorkoutLogTable.routineId: integer() → integer().nullable() - Log.routineId: late int → int? - Log constructor: required this.routineId → this.routineId - Log.toCompanion: handle null routineId with Value.absent() Fixes #1250
This commit is contained in:
@@ -65,7 +65,7 @@ class WorkoutLogTable extends Table {
|
||||
|
||||
TextColumn get id => text().clientDefault(() => ps.uuid.v7())();
|
||||
IntColumn get exerciseId => integer().named('exercise_id')();
|
||||
IntColumn get routineId => integer().named('routine_id')();
|
||||
IntColumn get routineId => integer().named('routine_id').nullable()();
|
||||
TextColumn get sessionId => text().named('session_id').nullable()();
|
||||
IntColumn get iteration => integer().nullable()();
|
||||
IntColumn get slotEntryId => integer().named('slot_entry_id').nullable()();
|
||||
|
||||
@@ -45,7 +45,7 @@ class Log {
|
||||
late int exerciseId;
|
||||
late Exercise exerciseObj;
|
||||
|
||||
late int routineId;
|
||||
int? routineId;
|
||||
String? sessionId;
|
||||
int? iteration;
|
||||
int? slotEntryId;
|
||||
@@ -69,7 +69,7 @@ class Log {
|
||||
required this.exerciseId,
|
||||
this.iteration,
|
||||
this.slotEntryId,
|
||||
required this.routineId,
|
||||
this.routineId,
|
||||
this.sessionId,
|
||||
this.repetitions,
|
||||
this.repetitionsTarget,
|
||||
@@ -166,7 +166,7 @@ class Log {
|
||||
return WorkoutLogTableCompanion(
|
||||
id: id != null ? drift.Value(id!) : const drift.Value.absent(),
|
||||
exerciseId: drift.Value(exerciseId),
|
||||
routineId: drift.Value(routineId),
|
||||
routineId: routineId != null ? drift.Value(routineId) : const drift.Value.absent(),
|
||||
sessionId: sessionId != null ? drift.Value(sessionId) : const drift.Value.absent(),
|
||||
iteration: iteration != null ? drift.Value(iteration) : const drift.Value.absent(),
|
||||
slotEntryId: slotEntryId != null ? drift.Value(slotEntryId) : const drift.Value.absent(),
|
||||
|
||||
Reference in New Issue
Block a user