description is now a required game parameter
This commit is contained in:
@@ -53,7 +53,7 @@ class GameDao extends DatabaseAccessor<AppDatabase> with _$GameDaoMixin {
|
|||||||
id: game.id,
|
id: game.id,
|
||||||
name: game.name,
|
name: game.name,
|
||||||
ruleset: game.ruleset ?? '',
|
ruleset: game.ruleset ?? '',
|
||||||
description: Value(game.description),
|
description: game.description,
|
||||||
color: game.color,
|
color: game.color,
|
||||||
icon: Value(game.icon),
|
icon: Value(game.icon),
|
||||||
createdAt: game.createdAt,
|
createdAt: game.createdAt,
|
||||||
@@ -79,7 +79,7 @@ class GameDao extends DatabaseAccessor<AppDatabase> with _$GameDaoMixin {
|
|||||||
id: game.id,
|
id: game.id,
|
||||||
name: game.name,
|
name: game.name,
|
||||||
ruleset: game.ruleset ?? '',
|
ruleset: game.ruleset ?? '',
|
||||||
description: Value(game.description),
|
description: game.description,
|
||||||
color: game.color,
|
color: game.color,
|
||||||
icon: Value(game.icon),
|
icon: Value(game.icon),
|
||||||
createdAt: game.createdAt,
|
createdAt: game.createdAt,
|
||||||
@@ -132,7 +132,7 @@ class GameDao extends DatabaseAccessor<AppDatabase> with _$GameDaoMixin {
|
|||||||
/// Updates the description of the game with the given [gameId].
|
/// Updates the description of the game with the given [gameId].
|
||||||
Future<void> updateGameDescription({
|
Future<void> updateGameDescription({
|
||||||
required String gameId,
|
required String gameId,
|
||||||
required String? newDescription,
|
required String newDescription,
|
||||||
}) async {
|
}) async {
|
||||||
await (update(gameTable)..where((g) => g.id.equals(gameId))).write(
|
await (update(gameTable)..where((g) => g.id.equals(gameId))).write(
|
||||||
GameTableCompanion(description: Value(newDescription)),
|
GameTableCompanion(description: Value(newDescription)),
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ class MatchDao extends DatabaseAccessor<AppDatabase> with _$MatchDaoMixin {
|
|||||||
id: game.id,
|
id: game.id,
|
||||||
name: game.name,
|
name: game.name,
|
||||||
ruleset: game.ruleset ?? '',
|
ruleset: game.ruleset ?? '',
|
||||||
description: Value(game.description),
|
description: game.description,
|
||||||
color: game.color,
|
color: game.color,
|
||||||
icon: Value(game.icon),
|
icon: Value(game.icon),
|
||||||
createdAt: game.createdAt,
|
createdAt: game.createdAt,
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ class AppDatabase extends _$AppDatabase {
|
|||||||
AppDatabase([QueryExecutor? executor]) : super(executor ?? _openConnection());
|
AppDatabase([QueryExecutor? executor]) : super(executor ?? _openConnection());
|
||||||
|
|
||||||
@override
|
@override
|
||||||
int get schemaVersion => 2;
|
int get schemaVersion => 1;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
MigrationStrategy get migration {
|
MigrationStrategy get migration {
|
||||||
|
|||||||
@@ -673,9 +673,9 @@ class $GameTableTable extends GameTable
|
|||||||
late final GeneratedColumn<String> description = GeneratedColumn<String>(
|
late final GeneratedColumn<String> description = GeneratedColumn<String>(
|
||||||
'description',
|
'description',
|
||||||
aliasedName,
|
aliasedName,
|
||||||
true,
|
false,
|
||||||
type: DriftSqlType.string,
|
type: DriftSqlType.string,
|
||||||
requiredDuringInsert: false,
|
requiredDuringInsert: true,
|
||||||
);
|
);
|
||||||
static const VerificationMeta _colorMeta = const VerificationMeta('color');
|
static const VerificationMeta _colorMeta = const VerificationMeta('color');
|
||||||
@override
|
@override
|
||||||
@@ -757,6 +757,8 @@ class $GameTableTable extends GameTable
|
|||||||
_descriptionMeta,
|
_descriptionMeta,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
} else if (isInserting) {
|
||||||
|
context.missing(_descriptionMeta);
|
||||||
}
|
}
|
||||||
if (data.containsKey('color')) {
|
if (data.containsKey('color')) {
|
||||||
context.handle(
|
context.handle(
|
||||||
@@ -804,7 +806,7 @@ class $GameTableTable extends GameTable
|
|||||||
description: attachedDatabase.typeMapping.read(
|
description: attachedDatabase.typeMapping.read(
|
||||||
DriftSqlType.string,
|
DriftSqlType.string,
|
||||||
data['${effectivePrefix}description'],
|
data['${effectivePrefix}description'],
|
||||||
),
|
)!,
|
||||||
color: attachedDatabase.typeMapping.read(
|
color: attachedDatabase.typeMapping.read(
|
||||||
DriftSqlType.string,
|
DriftSqlType.string,
|
||||||
data['${effectivePrefix}color'],
|
data['${effectivePrefix}color'],
|
||||||
@@ -830,7 +832,7 @@ class GameTableData extends DataClass implements Insertable<GameTableData> {
|
|||||||
final String id;
|
final String id;
|
||||||
final String name;
|
final String name;
|
||||||
final String ruleset;
|
final String ruleset;
|
||||||
final String? description;
|
final String description;
|
||||||
final String color;
|
final String color;
|
||||||
final String? icon;
|
final String? icon;
|
||||||
final DateTime createdAt;
|
final DateTime createdAt;
|
||||||
@@ -838,7 +840,7 @@ class GameTableData extends DataClass implements Insertable<GameTableData> {
|
|||||||
required this.id,
|
required this.id,
|
||||||
required this.name,
|
required this.name,
|
||||||
required this.ruleset,
|
required this.ruleset,
|
||||||
this.description,
|
required this.description,
|
||||||
required this.color,
|
required this.color,
|
||||||
this.icon,
|
this.icon,
|
||||||
required this.createdAt,
|
required this.createdAt,
|
||||||
@@ -849,9 +851,7 @@ class GameTableData extends DataClass implements Insertable<GameTableData> {
|
|||||||
map['id'] = Variable<String>(id);
|
map['id'] = Variable<String>(id);
|
||||||
map['name'] = Variable<String>(name);
|
map['name'] = Variable<String>(name);
|
||||||
map['ruleset'] = Variable<String>(ruleset);
|
map['ruleset'] = Variable<String>(ruleset);
|
||||||
if (!nullToAbsent || description != null) {
|
|
||||||
map['description'] = Variable<String>(description);
|
map['description'] = Variable<String>(description);
|
||||||
}
|
|
||||||
map['color'] = Variable<String>(color);
|
map['color'] = Variable<String>(color);
|
||||||
if (!nullToAbsent || icon != null) {
|
if (!nullToAbsent || icon != null) {
|
||||||
map['icon'] = Variable<String>(icon);
|
map['icon'] = Variable<String>(icon);
|
||||||
@@ -865,9 +865,7 @@ class GameTableData extends DataClass implements Insertable<GameTableData> {
|
|||||||
id: Value(id),
|
id: Value(id),
|
||||||
name: Value(name),
|
name: Value(name),
|
||||||
ruleset: Value(ruleset),
|
ruleset: Value(ruleset),
|
||||||
description: description == null && nullToAbsent
|
description: Value(description),
|
||||||
? const Value.absent()
|
|
||||||
: Value(description),
|
|
||||||
color: Value(color),
|
color: Value(color),
|
||||||
icon: icon == null && nullToAbsent ? const Value.absent() : Value(icon),
|
icon: icon == null && nullToAbsent ? const Value.absent() : Value(icon),
|
||||||
createdAt: Value(createdAt),
|
createdAt: Value(createdAt),
|
||||||
@@ -883,7 +881,7 @@ class GameTableData extends DataClass implements Insertable<GameTableData> {
|
|||||||
id: serializer.fromJson<String>(json['id']),
|
id: serializer.fromJson<String>(json['id']),
|
||||||
name: serializer.fromJson<String>(json['name']),
|
name: serializer.fromJson<String>(json['name']),
|
||||||
ruleset: serializer.fromJson<String>(json['ruleset']),
|
ruleset: serializer.fromJson<String>(json['ruleset']),
|
||||||
description: serializer.fromJson<String?>(json['description']),
|
description: serializer.fromJson<String>(json['description']),
|
||||||
color: serializer.fromJson<String>(json['color']),
|
color: serializer.fromJson<String>(json['color']),
|
||||||
icon: serializer.fromJson<String?>(json['icon']),
|
icon: serializer.fromJson<String?>(json['icon']),
|
||||||
createdAt: serializer.fromJson<DateTime>(json['createdAt']),
|
createdAt: serializer.fromJson<DateTime>(json['createdAt']),
|
||||||
@@ -896,7 +894,7 @@ class GameTableData extends DataClass implements Insertable<GameTableData> {
|
|||||||
'id': serializer.toJson<String>(id),
|
'id': serializer.toJson<String>(id),
|
||||||
'name': serializer.toJson<String>(name),
|
'name': serializer.toJson<String>(name),
|
||||||
'ruleset': serializer.toJson<String>(ruleset),
|
'ruleset': serializer.toJson<String>(ruleset),
|
||||||
'description': serializer.toJson<String?>(description),
|
'description': serializer.toJson<String>(description),
|
||||||
'color': serializer.toJson<String>(color),
|
'color': serializer.toJson<String>(color),
|
||||||
'icon': serializer.toJson<String?>(icon),
|
'icon': serializer.toJson<String?>(icon),
|
||||||
'createdAt': serializer.toJson<DateTime>(createdAt),
|
'createdAt': serializer.toJson<DateTime>(createdAt),
|
||||||
@@ -907,7 +905,7 @@ class GameTableData extends DataClass implements Insertable<GameTableData> {
|
|||||||
String? id,
|
String? id,
|
||||||
String? name,
|
String? name,
|
||||||
String? ruleset,
|
String? ruleset,
|
||||||
Value<String?> description = const Value.absent(),
|
String? description,
|
||||||
String? color,
|
String? color,
|
||||||
Value<String?> icon = const Value.absent(),
|
Value<String?> icon = const Value.absent(),
|
||||||
DateTime? createdAt,
|
DateTime? createdAt,
|
||||||
@@ -915,7 +913,7 @@ class GameTableData extends DataClass implements Insertable<GameTableData> {
|
|||||||
id: id ?? this.id,
|
id: id ?? this.id,
|
||||||
name: name ?? this.name,
|
name: name ?? this.name,
|
||||||
ruleset: ruleset ?? this.ruleset,
|
ruleset: ruleset ?? this.ruleset,
|
||||||
description: description.present ? description.value : this.description,
|
description: description ?? this.description,
|
||||||
color: color ?? this.color,
|
color: color ?? this.color,
|
||||||
icon: icon.present ? icon.value : this.icon,
|
icon: icon.present ? icon.value : this.icon,
|
||||||
createdAt: createdAt ?? this.createdAt,
|
createdAt: createdAt ?? this.createdAt,
|
||||||
@@ -968,7 +966,7 @@ class GameTableCompanion extends UpdateCompanion<GameTableData> {
|
|||||||
final Value<String> id;
|
final Value<String> id;
|
||||||
final Value<String> name;
|
final Value<String> name;
|
||||||
final Value<String> ruleset;
|
final Value<String> ruleset;
|
||||||
final Value<String?> description;
|
final Value<String> description;
|
||||||
final Value<String> color;
|
final Value<String> color;
|
||||||
final Value<String?> icon;
|
final Value<String?> icon;
|
||||||
final Value<DateTime> createdAt;
|
final Value<DateTime> createdAt;
|
||||||
@@ -987,7 +985,7 @@ class GameTableCompanion extends UpdateCompanion<GameTableData> {
|
|||||||
required String id,
|
required String id,
|
||||||
required String name,
|
required String name,
|
||||||
required String ruleset,
|
required String ruleset,
|
||||||
this.description = const Value.absent(),
|
required String description,
|
||||||
required String color,
|
required String color,
|
||||||
this.icon = const Value.absent(),
|
this.icon = const Value.absent(),
|
||||||
required DateTime createdAt,
|
required DateTime createdAt,
|
||||||
@@ -995,6 +993,7 @@ class GameTableCompanion extends UpdateCompanion<GameTableData> {
|
|||||||
}) : id = Value(id),
|
}) : id = Value(id),
|
||||||
name = Value(name),
|
name = Value(name),
|
||||||
ruleset = Value(ruleset),
|
ruleset = Value(ruleset),
|
||||||
|
description = Value(description),
|
||||||
color = Value(color),
|
color = Value(color),
|
||||||
createdAt = Value(createdAt);
|
createdAt = Value(createdAt);
|
||||||
static Insertable<GameTableData> custom({
|
static Insertable<GameTableData> custom({
|
||||||
@@ -1023,7 +1022,7 @@ class GameTableCompanion extends UpdateCompanion<GameTableData> {
|
|||||||
Value<String>? id,
|
Value<String>? id,
|
||||||
Value<String>? name,
|
Value<String>? name,
|
||||||
Value<String>? ruleset,
|
Value<String>? ruleset,
|
||||||
Value<String?>? description,
|
Value<String>? description,
|
||||||
Value<String>? color,
|
Value<String>? color,
|
||||||
Value<String?>? icon,
|
Value<String?>? icon,
|
||||||
Value<DateTime>? createdAt,
|
Value<DateTime>? createdAt,
|
||||||
@@ -3663,7 +3662,7 @@ typedef $$GameTableTableCreateCompanionBuilder =
|
|||||||
required String id,
|
required String id,
|
||||||
required String name,
|
required String name,
|
||||||
required String ruleset,
|
required String ruleset,
|
||||||
Value<String?> description,
|
required String description,
|
||||||
required String color,
|
required String color,
|
||||||
Value<String?> icon,
|
Value<String?> icon,
|
||||||
required DateTime createdAt,
|
required DateTime createdAt,
|
||||||
@@ -3674,7 +3673,7 @@ typedef $$GameTableTableUpdateCompanionBuilder =
|
|||||||
Value<String> id,
|
Value<String> id,
|
||||||
Value<String> name,
|
Value<String> name,
|
||||||
Value<String> ruleset,
|
Value<String> ruleset,
|
||||||
Value<String?> description,
|
Value<String> description,
|
||||||
Value<String> color,
|
Value<String> color,
|
||||||
Value<String?> icon,
|
Value<String?> icon,
|
||||||
Value<DateTime> createdAt,
|
Value<DateTime> createdAt,
|
||||||
@@ -3908,7 +3907,7 @@ class $$GameTableTableTableManager
|
|||||||
Value<String> id = const Value.absent(),
|
Value<String> id = const Value.absent(),
|
||||||
Value<String> name = const Value.absent(),
|
Value<String> name = const Value.absent(),
|
||||||
Value<String> ruleset = const Value.absent(),
|
Value<String> ruleset = const Value.absent(),
|
||||||
Value<String?> description = const Value.absent(),
|
Value<String> description = const Value.absent(),
|
||||||
Value<String> color = const Value.absent(),
|
Value<String> color = const Value.absent(),
|
||||||
Value<String?> icon = const Value.absent(),
|
Value<String?> icon = const Value.absent(),
|
||||||
Value<DateTime> createdAt = const Value.absent(),
|
Value<DateTime> createdAt = const Value.absent(),
|
||||||
@@ -3928,7 +3927,7 @@ class $$GameTableTableTableManager
|
|||||||
required String id,
|
required String id,
|
||||||
required String name,
|
required String name,
|
||||||
required String ruleset,
|
required String ruleset,
|
||||||
Value<String?> description = const Value.absent(),
|
required String description,
|
||||||
required String color,
|
required String color,
|
||||||
Value<String?> icon = const Value.absent(),
|
Value<String?> icon = const Value.absent(),
|
||||||
required DateTime createdAt,
|
required DateTime createdAt,
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ class GameTable extends Table {
|
|||||||
TextColumn get id => text()();
|
TextColumn get id => text()();
|
||||||
TextColumn get name => text()();
|
TextColumn get name => text()();
|
||||||
TextColumn get ruleset => text()();
|
TextColumn get ruleset => text()();
|
||||||
TextColumn get description => text().nullable()();
|
TextColumn get description => text()();
|
||||||
TextColumn get color => text()();
|
TextColumn get color => text()();
|
||||||
TextColumn get icon => text().nullable()();
|
TextColumn get icon => text().nullable()();
|
||||||
DateTimeColumn get createdAt => dateTime()();
|
DateTimeColumn get createdAt => dateTime()();
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ class Game {
|
|||||||
final DateTime createdAt;
|
final DateTime createdAt;
|
||||||
final String name;
|
final String name;
|
||||||
final String? ruleset;
|
final String? ruleset;
|
||||||
final String? description;
|
final String description;
|
||||||
final String color;
|
final String color;
|
||||||
final String? icon;
|
final String? icon;
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@ class Game {
|
|||||||
DateTime? createdAt,
|
DateTime? createdAt,
|
||||||
required this.name,
|
required this.name,
|
||||||
this.ruleset,
|
this.ruleset,
|
||||||
this.description,
|
required this.description,
|
||||||
required this.color,
|
required this.color,
|
||||||
this.icon,
|
this.icon,
|
||||||
}) : id = id ?? const Uuid().v4(),
|
}) : id = id ?? const Uuid().v4(),
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ void main() {
|
|||||||
|
|
||||||
// Verifies that a game with null optional fields can be added and retrieved.
|
// Verifies that a game with null optional fields can be added and retrieved.
|
||||||
test('addGame handles game with null optional fields', () async {
|
test('addGame handles game with null optional fields', () async {
|
||||||
final gameWithNulls = Game(name: 'Simple Game', color: '0xFF000000');
|
final gameWithNulls = Game(name: 'Simple Game', description: 'A simple game', color: '0xFF000000');
|
||||||
final result = await database.gameDao.addGame(game: gameWithNulls);
|
final result = await database.gameDao.addGame(game: gameWithNulls);
|
||||||
expect(result, true);
|
expect(result, true);
|
||||||
|
|
||||||
@@ -139,7 +139,7 @@ void main() {
|
|||||||
gameId: gameWithNulls.id,
|
gameId: gameWithNulls.id,
|
||||||
);
|
);
|
||||||
expect(fetchedGame.name, 'Simple Game');
|
expect(fetchedGame.name, 'Simple Game');
|
||||||
expect(fetchedGame.description, isNull);
|
expect(fetchedGame.description, 'A simple game');
|
||||||
expect(fetchedGame.color, '0xFF000000');
|
expect(fetchedGame.color, '0xFF000000');
|
||||||
expect(fetchedGame.icon, isNull);
|
expect(fetchedGame.icon, isNull);
|
||||||
});
|
});
|
||||||
@@ -305,19 +305,19 @@ void main() {
|
|||||||
expect(updatedGame.description, 'An updated description');
|
expect(updatedGame.description, 'An updated description');
|
||||||
});
|
});
|
||||||
|
|
||||||
// Verifies that updateGameDescription can set the description to null.
|
// Verifies that updateGameDescription can set the description to an empty string.
|
||||||
test('updateGameDescription can set description to null', () async {
|
test('updateGameDescription can set description to empty string', () async {
|
||||||
await database.gameDao.addGame(game: testGame1);
|
await database.gameDao.addGame(game: testGame1);
|
||||||
|
|
||||||
await database.gameDao.updateGameDescription(
|
await database.gameDao.updateGameDescription(
|
||||||
gameId: testGame1.id,
|
gameId: testGame1.id,
|
||||||
newDescription: null,
|
newDescription: '',
|
||||||
);
|
);
|
||||||
|
|
||||||
final updatedGame = await database.gameDao.getGameById(
|
final updatedGame = await database.gameDao.getGameById(
|
||||||
gameId: testGame1.id,
|
gameId: testGame1.id,
|
||||||
);
|
);
|
||||||
expect(updatedGame.description, isNull);
|
expect(updatedGame.description, '');
|
||||||
});
|
});
|
||||||
|
|
||||||
// Verifies that updateGameDescription does nothing when game doesn't exist.
|
// Verifies that updateGameDescription does nothing when game doesn't exist.
|
||||||
@@ -502,7 +502,7 @@ void main() {
|
|||||||
gameId: longGame.id,
|
gameId: longGame.id,
|
||||||
);
|
);
|
||||||
expect(fetchedGame.name.length, 10000);
|
expect(fetchedGame.name.length, 10000);
|
||||||
expect(fetchedGame.description?.length, 10000);
|
expect(fetchedGame.description.length, 10000);
|
||||||
expect(fetchedGame.ruleset?.length, 10000);
|
expect(fetchedGame.ruleset?.length, 10000);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ void main() {
|
|||||||
name: 'Test Group 2',
|
name: 'Test Group 2',
|
||||||
members: [testPlayer4, testPlayer5],
|
members: [testPlayer4, testPlayer5],
|
||||||
);
|
);
|
||||||
testGame = Game(name: 'Test Game', color: '0xFF000000');
|
testGame = Game(name: 'Test Game', description: 'A test game', color: '0xFF000000');
|
||||||
testMatch1 = Match(
|
testMatch1 = Match(
|
||||||
name: 'First Test Match',
|
name: 'First Test Match',
|
||||||
game: testGame,
|
game: testGame,
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ void main() {
|
|||||||
name: 'Test Group',
|
name: 'Test Group',
|
||||||
members: [testPlayer1, testPlayer2, testPlayer3],
|
members: [testPlayer1, testPlayer2, testPlayer3],
|
||||||
);
|
);
|
||||||
testGame = Game(name: 'Test Game', color: '0xFF000000');
|
testGame = Game(name: 'Test Game', description: 'A test game', color: '0xFF000000');
|
||||||
testMatchOnlyGroup = Match(
|
testMatchOnlyGroup = Match(
|
||||||
name: 'Test Match with Group',
|
name: 'Test Match with Group',
|
||||||
game: testGame,
|
game: testGame,
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ void main() {
|
|||||||
testPlayer1 = Player(name: 'Alice');
|
testPlayer1 = Player(name: 'Alice');
|
||||||
testPlayer2 = Player(name: 'Bob');
|
testPlayer2 = Player(name: 'Bob');
|
||||||
testPlayer3 = Player(name: 'Charlie');
|
testPlayer3 = Player(name: 'Charlie');
|
||||||
testGame = Game(name: 'Test Game', color: '0xFF000000');
|
testGame = Game(name: 'Test Game', description: 'A test game', color: '0xFF000000');
|
||||||
testMatch1 = Match(
|
testMatch1 = Match(
|
||||||
name: 'Test Match 1',
|
name: 'Test Match 1',
|
||||||
game: testGame,
|
game: testGame,
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ void main() {
|
|||||||
name: 'Team Gamma',
|
name: 'Team Gamma',
|
||||||
members: [testPlayer1, testPlayer3],
|
members: [testPlayer1, testPlayer3],
|
||||||
);
|
);
|
||||||
testGame1 = Game(name: 'Game 1', color: '0xFF000000');
|
testGame1 = Game(name: 'Game 1', description: 'Test game 1', color: '0xFF000000');
|
||||||
testGame2 = Game(name: 'Game 2', color: '0xFF000000');
|
testGame2 = Game(name: 'Game 2', description: 'Test game 2', color: '0xFF000000');
|
||||||
});
|
});
|
||||||
|
|
||||||
await database.playerDao.addPlayersAsList(
|
await database.playerDao.addPlayersAsList(
|
||||||
|
|||||||
Reference in New Issue
Block a user