diff --git a/lib/data/dao/match_dao.dart b/lib/data/dao/match_dao.dart index f43909c..6959b1b 100644 --- a/lib/data/dao/match_dao.dart +++ b/lib/data/dao/match_dao.dart @@ -30,7 +30,7 @@ class MatchDao extends DatabaseAccessor with _$MatchDaoMixin { gameId: match.game.id, groupId: Value(match.group?.id), name: match.name, - notes: Value(match.notes), + notes: match.notes, createdAt: match.createdAt, endedAt: Value(match.endedAt), ), @@ -142,7 +142,7 @@ class MatchDao extends DatabaseAccessor with _$MatchDaoMixin { gameId: match.game.id, groupId: Value(match.group?.id), name: match.name, - notes: Value(match.notes), + notes: match.notes, createdAt: match.createdAt, endedAt: Value(match.endedAt), ), @@ -300,7 +300,7 @@ class MatchDao extends DatabaseAccessor with _$MatchDaoMixin { group: group, players: players, teams: teams.isEmpty ? null : teams, - notes: row.notes ?? '', + notes: row.notes, createdAt: row.createdAt, endedAt: row.endedAt, scores: scores, @@ -334,7 +334,7 @@ class MatchDao extends DatabaseAccessor with _$MatchDaoMixin { group: group, players: players, teams: teams.isEmpty ? null : teams, - notes: result.notes ?? '', + notes: result.notes, createdAt: result.createdAt, endedAt: result.endedAt, scores: scores, @@ -362,7 +362,7 @@ class MatchDao extends DatabaseAccessor with _$MatchDaoMixin { group: group, players: players, teams: teams.isEmpty ? null : teams, - notes: row.notes ?? '', + notes: row.notes, createdAt: row.createdAt, endedAt: row.endedAt, ); diff --git a/lib/data/db/database.g.dart b/lib/data/db/database.g.dart index b4f3702..c8d0faa 100644 --- a/lib/data/db/database.g.dart +++ b/lib/data/db/database.g.dart @@ -1190,9 +1190,9 @@ class $MatchTableTable extends MatchTable late final GeneratedColumn notes = GeneratedColumn( 'notes', aliasedName, - true, + false, type: DriftSqlType.string, - requiredDuringInsert: false, + requiredDuringInsert: true, ); static const VerificationMeta _createdAtMeta = const VerificationMeta( 'createdAt', @@ -1270,6 +1270,8 @@ class $MatchTableTable extends MatchTable _notesMeta, notes.isAcceptableOrUnknown(data['notes']!, _notesMeta), ); + } else if (isInserting) { + context.missing(_notesMeta); } if (data.containsKey('created_at')) { context.handle( @@ -1313,7 +1315,7 @@ class $MatchTableTable extends MatchTable notes: attachedDatabase.typeMapping.read( DriftSqlType.string, data['${effectivePrefix}notes'], - ), + )!, createdAt: attachedDatabase.typeMapping.read( DriftSqlType.dateTime, data['${effectivePrefix}created_at'], @@ -1336,7 +1338,7 @@ class MatchTableData extends DataClass implements Insertable { final String gameId; final String? groupId; final String name; - final String? notes; + final String notes; final DateTime createdAt; final DateTime? endedAt; const MatchTableData({ @@ -1344,7 +1346,7 @@ class MatchTableData extends DataClass implements Insertable { required this.gameId, this.groupId, required this.name, - this.notes, + required this.notes, required this.createdAt, this.endedAt, }); @@ -1357,9 +1359,7 @@ class MatchTableData extends DataClass implements Insertable { map['group_id'] = Variable(groupId); } map['name'] = Variable(name); - if (!nullToAbsent || notes != null) { - map['notes'] = Variable(notes); - } + map['notes'] = Variable(notes); map['created_at'] = Variable(createdAt); if (!nullToAbsent || endedAt != null) { map['ended_at'] = Variable(endedAt); @@ -1375,9 +1375,7 @@ class MatchTableData extends DataClass implements Insertable { ? const Value.absent() : Value(groupId), name: Value(name), - notes: notes == null && nullToAbsent - ? const Value.absent() - : Value(notes), + notes: Value(notes), createdAt: Value(createdAt), endedAt: endedAt == null && nullToAbsent ? const Value.absent() @@ -1395,7 +1393,7 @@ class MatchTableData extends DataClass implements Insertable { gameId: serializer.fromJson(json['gameId']), groupId: serializer.fromJson(json['groupId']), name: serializer.fromJson(json['name']), - notes: serializer.fromJson(json['notes']), + notes: serializer.fromJson(json['notes']), createdAt: serializer.fromJson(json['createdAt']), endedAt: serializer.fromJson(json['endedAt']), ); @@ -1408,7 +1406,7 @@ class MatchTableData extends DataClass implements Insertable { 'gameId': serializer.toJson(gameId), 'groupId': serializer.toJson(groupId), 'name': serializer.toJson(name), - 'notes': serializer.toJson(notes), + 'notes': serializer.toJson(notes), 'createdAt': serializer.toJson(createdAt), 'endedAt': serializer.toJson(endedAt), }; @@ -1419,7 +1417,7 @@ class MatchTableData extends DataClass implements Insertable { String? gameId, Value groupId = const Value.absent(), String? name, - Value notes = const Value.absent(), + String? notes, DateTime? createdAt, Value endedAt = const Value.absent(), }) => MatchTableData( @@ -1427,7 +1425,7 @@ class MatchTableData extends DataClass implements Insertable { gameId: gameId ?? this.gameId, groupId: groupId.present ? groupId.value : this.groupId, name: name ?? this.name, - notes: notes.present ? notes.value : this.notes, + notes: notes ?? this.notes, createdAt: createdAt ?? this.createdAt, endedAt: endedAt.present ? endedAt.value : this.endedAt, ); @@ -1478,7 +1476,7 @@ class MatchTableCompanion extends UpdateCompanion { final Value gameId; final Value groupId; final Value name; - final Value notes; + final Value notes; final Value createdAt; final Value endedAt; final Value rowid; @@ -1497,13 +1495,14 @@ class MatchTableCompanion extends UpdateCompanion { required String gameId, this.groupId = const Value.absent(), required String name, - this.notes = const Value.absent(), + required String notes, required DateTime createdAt, this.endedAt = const Value.absent(), this.rowid = const Value.absent(), }) : id = Value(id), gameId = Value(gameId), name = Value(name), + notes = Value(notes), createdAt = Value(createdAt); static Insertable custom({ Expression? id, @@ -1532,7 +1531,7 @@ class MatchTableCompanion extends UpdateCompanion { Value? gameId, Value? groupId, Value? name, - Value? notes, + Value? notes, Value? createdAt, Value? endedAt, Value? rowid, @@ -4093,7 +4092,7 @@ typedef $$MatchTableTableCreateCompanionBuilder = required String gameId, Value groupId, required String name, - Value notes, + required String notes, required DateTime createdAt, Value endedAt, Value rowid, @@ -4104,7 +4103,7 @@ typedef $$MatchTableTableUpdateCompanionBuilder = Value gameId, Value groupId, Value name, - Value notes, + Value notes, Value createdAt, Value endedAt, Value rowid, @@ -4567,7 +4566,7 @@ class $$MatchTableTableTableManager Value gameId = const Value.absent(), Value groupId = const Value.absent(), Value name = const Value.absent(), - Value notes = const Value.absent(), + Value notes = const Value.absent(), Value createdAt = const Value.absent(), Value endedAt = const Value.absent(), Value rowid = const Value.absent(), @@ -4587,7 +4586,7 @@ class $$MatchTableTableTableManager required String gameId, Value groupId = const Value.absent(), required String name, - Value notes = const Value.absent(), + required String notes, required DateTime createdAt, Value endedAt = const Value.absent(), Value rowid = const Value.absent(), diff --git a/lib/data/db/tables/match_table.dart b/lib/data/db/tables/match_table.dart index 25b0a73..c565547 100644 --- a/lib/data/db/tables/match_table.dart +++ b/lib/data/db/tables/match_table.dart @@ -12,7 +12,7 @@ class MatchTable extends Table { .references(GroupTable, #id, onDelete: KeyAction.setNull) .nullable()(); TextColumn get name => text()(); - TextColumn get notes => text().nullable()(); + TextColumn get notes => text()(); DateTimeColumn get createdAt => dateTime()(); DateTimeColumn get endedAt => dateTime().nullable()();