Skip to content

Commit

Permalink
chore(persistence): fix drift generated code and tests (#2039)
Browse files Browse the repository at this point in the history
  • Loading branch information
xsahil03x authored Oct 22, 2024
1 parent 92e4fcd commit 7373a49
Show file tree
Hide file tree
Showing 8 changed files with 128 additions and 106 deletions.
204 changes: 102 additions & 102 deletions packages/stream_chat_persistence/lib/src/db/drift_chat_database.g.dart

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Channels extends Table {
TextColumn get createdById => text().nullable()();

/// Map of custom channel extraData
TextColumn get extraData => text().nullable().map(MapConverter<Object?>())();
TextColumn get extraData => text().nullable().map(MapConverter())();

@override
Set<Column> get primaryKey => {cid};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class Messages extends Table {
text().nullable().map(NullableMapConverter<String>())();

/// Message custom extraData
TextColumn get extraData => text().nullable().map(MapConverter<Object?>())();
TextColumn get extraData => text().nullable().map(MapConverter())();

@override
Set<Column> get primaryKey => {id};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Reactions extends Table {
IntColumn get score => integer().withDefault(const Constant(0))();

/// Reaction custom extraData
TextColumn get extraData => text().nullable().map(MapConverter<Object?>())();
TextColumn get extraData => text().nullable().map(MapConverter())();

@override
Set<Column> get primaryKey => {
Expand Down
2 changes: 1 addition & 1 deletion packages/stream_chat_persistence/lib/src/entity/users.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Users extends Table {
BoolColumn get banned => boolean().withDefault(const Constant(false))();

/// Map of custom user extraData
TextColumn get extraData => text().map(MapConverter<Object?>())();
TextColumn get extraData => text().map(MapConverter())();

@override
Set<Column> get primaryKey => {id};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ extension PinnedMessageEntityX on PinnedMessageEntity {
localUpdatedAt: localUpdatedAt,
deletedAt: remoteDeletedAt,
localDeletedAt: localDeletedAt,
messageTextUpdatedAt: messageTextUpdatedAt,
id: id,
type: type,
state: MessageState.fromJson(jsonDecode(state)),
Expand Down Expand Up @@ -78,6 +79,7 @@ extension PMessageX on Message {
userId: user?.id,
remoteDeletedAt: remoteDeletedAt,
localDeletedAt: localDeletedAt,
messageTextUpdatedAt: messageTextUpdatedAt,
messageText: text,
pinned: pinned,
pinnedAt: pinnedAt,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ void main() {
state: jsonEncode(MessageState.sent),
localUpdatedAt: DateTime.now(),
remoteUpdatedAt: DateTime.now().add(const Duration(seconds: 1)),
messageTextUpdatedAt: DateTime.now().add(const Duration(minutes: 5)),
extraData: {'extra_test_data': 'extraData'},
userId: user.id,
localDeletedAt: DateTime.now(),
Expand Down Expand Up @@ -99,6 +100,10 @@ void main() {
expect(message.state, MessageState.fromJson(jsonDecode(entity.state)));
expect(message.localUpdatedAt, isSameDateAs(entity.localUpdatedAt));
expect(message.remoteUpdatedAt, isSameDateAs(entity.remoteUpdatedAt));
expect(
message.messageTextUpdatedAt,
isSameDateAs(entity.messageTextUpdatedAt),
);
expect(message.extraData, entity.extraData);
expect(message.user!.id, entity.userId);
expect(message.localDeletedAt, isSameDateAs(entity.localDeletedAt));
Expand Down Expand Up @@ -166,6 +171,7 @@ void main() {
),
localUpdatedAt: DateTime.now(),
updatedAt: DateTime.now().add(const Duration(seconds: 1)),
messageTextUpdatedAt: DateTime.now().add(const Duration(minutes: 5)),
extraData: const {'extra_test_data': 'extraData'},
user: user,
localDeletedAt: DateTime.now(),
Expand Down Expand Up @@ -200,6 +206,10 @@ void main() {
expect(entity.state, jsonEncode(message.state));
expect(entity.localUpdatedAt, isSameDateAs(message.localUpdatedAt));
expect(entity.remoteUpdatedAt, isSameDateAs(message.remoteUpdatedAt));
expect(
entity.messageTextUpdatedAt,
isSameDateAs(message.messageTextUpdatedAt),
);
expect(entity.extraData, message.extraData);
expect(entity.userId, message.user!.id);
expect(entity.localDeletedAt, isSameDateAs(message.localDeletedAt));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ void main() {
state: jsonEncode(MessageState.sent),
localUpdatedAt: DateTime.now(),
remoteUpdatedAt: DateTime.now().add(const Duration(seconds: 1)),
messageTextUpdatedAt: DateTime.now().add(const Duration(minutes: 5)),
extraData: {'extra_test_data': 'extraData'},
userId: user.id,
localDeletedAt: DateTime.now(),
Expand Down Expand Up @@ -99,6 +100,10 @@ void main() {
expect(message.state, MessageState.fromJson(jsonDecode(entity.state)));
expect(message.localUpdatedAt, isSameDateAs(entity.localUpdatedAt));
expect(message.remoteUpdatedAt, isSameDateAs(entity.remoteUpdatedAt));
expect(
message.messageTextUpdatedAt,
isSameDateAs(entity.messageTextUpdatedAt),
);
expect(message.extraData, entity.extraData);
expect(message.user!.id, entity.userId);
expect(message.localDeletedAt, isSameDateAs(entity.localDeletedAt));
Expand Down Expand Up @@ -166,6 +171,7 @@ void main() {
),
localUpdatedAt: DateTime.now(),
updatedAt: DateTime.now().add(const Duration(seconds: 1)),
messageTextUpdatedAt: DateTime.now().add(const Duration(minutes: 5)),
extraData: const {'extra_test_data': 'extraData'},
user: user,
localDeletedAt: DateTime.now(),
Expand Down Expand Up @@ -200,6 +206,10 @@ void main() {
expect(entity.state, jsonEncode(message.state));
expect(entity.localUpdatedAt, isSameDateAs(message.localUpdatedAt));
expect(entity.remoteUpdatedAt, isSameDateAs(message.remoteUpdatedAt));
expect(
message.messageTextUpdatedAt,
isSameDateAs(entity.messageTextUpdatedAt),
);
expect(entity.extraData, message.extraData);
expect(entity.userId, message.user!.id);
expect(entity.localDeletedAt, isSameDateAs(message.localDeletedAt));
Expand Down

0 comments on commit 7373a49

Please sign in to comment.