From cb7faba67b30f4f215764ffac1db6998bd2ea5ae Mon Sep 17 00:00:00 2001 From: Roland Geider Date: Mon, 24 Aug 2026 15:56:23 +0200 Subject: [PATCH] Keep a profile save away from the timezone column --- lib/features/account/models/user_profile.dart | 4 +++- .../providers/user_profile_repository_test.dart | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/features/account/models/user_profile.dart b/lib/features/account/models/user_profile.dart index 161bdda9f..49b2fff70 100644 --- a/lib/features/account/models/user_profile.dart +++ b/lib/features/account/models/user_profile.dart @@ -44,12 +44,14 @@ class UserProfile { int get defaultWeightUnitId => isMetric ? WEIGHT_UNIT_KG : WEIGHT_UNIT_LB; /// Drift companion for local UPDATE writes routed through PowerSync. + /// + /// Only the columns the profile form edits: the timezone column belongs to + /// TimezoneSync, and a full write would clear what another client reported. UserProfileTableCompanion toCompanion() { return UserProfileTableCompanion( id: drift.Value(id), weightUnitStr: drift.Value(weightUnitStr), height: drift.Value(height), - timeZone: drift.Value(timeZone), ); } } diff --git a/test/features/account/providers/user_profile_repository_test.dart b/test/features/account/providers/user_profile_repository_test.dart index 1d08e120f..686316bab 100644 --- a/test/features/account/providers/user_profile_repository_test.dart +++ b/test/features/account/providers/user_profile_repository_test.dart @@ -114,6 +114,18 @@ void main() { expect(row.height, 178); }); + test('leaves the reported timezone alone', () async { + // The column belongs to TimezoneSync; the server rejects it as null, + // taking the rest of the profile write down with it + await seed(); + await repo.updateTimeZoneDrift(1, 'Pacific/Auckland'); + + await repo.editLocalDrift(UserProfile(id: 1, weightUnitStr: 'lb')); + + final row = await db.select(db.userProfileTable).getSingle(); + expect(row.timeZone, 'Pacific/Auckland'); + }); + test('clears the height when the profile has none', () async { // The server allows a profile without one, so an emptied field has to // reach the column as NULL rather than leaving the old value standing