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:
Mustafa Senoglu committed 2026-07-09 14:15:04 +03:00
1 parent 4a8a1d6d00
commit cc483f3dae
2 files changed
+4 -4

No files matched your search

+1 -1
View File
@@ -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()();