Merge branch 'development' into refactoring/105-fehlende-umbenennungen
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m18s
Pull Request Pipeline / lint (pull_request) Successful in 2m18s

This commit is contained in:
2025-12-30 21:22:34 +01:00
6 changed files with 112 additions and 16 deletions

View File

@@ -21,7 +21,7 @@ class GroupMatchDao extends DatabaseAccessor<AppDatabase>
}
await into(groupMatchTable).insert(
GroupMatchTableCompanion.insert(groupId: groupId, matchId: matchId),
mode: InsertMode.insertOrReplace,
mode: InsertMode.insertOrIgnore,
);
}

View File

@@ -65,8 +65,9 @@ class MatchDao extends DatabaseAccessor<AppDatabase> with _$MatchDaoMixin {
);
}
/// Adds a new [Match] to the database.
/// Also adds associated players and group if they exist.
/// Adds a new [Match] to the database. Also adds players and group
/// associations. This method assumes that the players and groups added to
/// this match are already present in the database.
Future<void> addMatch({required Match match}) async {
await db.transaction(() async {
await into(matchTable).insert(
@@ -80,7 +81,6 @@ class MatchDao extends DatabaseAccessor<AppDatabase> with _$MatchDaoMixin {
);
if (match.players != null) {
await db.playerDao.addPlayersAsList(players: match.players!);
for (final p in match.players ?? []) {
await db.playerMatchDao.addPlayerToMatch(
matchId: match.id,
@@ -90,7 +90,6 @@ class MatchDao extends DatabaseAccessor<AppDatabase> with _$MatchDaoMixin {
}
if (match.group != null) {
await db.groupDao.addGroup(group: match.group!);
await db.groupMatchDao.addGroupToMatch(
matchId: match.id,
groupId: match.group!.id,
@@ -102,6 +101,7 @@ class MatchDao extends DatabaseAccessor<AppDatabase> with _$MatchDaoMixin {
/// Adds multiple [Match]s to the database in a batch operation.
/// Also adds associated players and groups if they exist.
/// If the [matches] list is empty, the method returns immediately.
/// This Method should only be used to import matches from a different device.
Future<void> addMatchAsList({required List<Match> matches}) async {
if (matches.isEmpty) return;
await db.transaction(() async {
@@ -186,7 +186,7 @@ class MatchDao extends DatabaseAccessor<AppDatabase> with _$MatchDaoMixin {
matchId: match.id,
playerId: p.id,
),
mode: InsertMode.insertOrReplace,
mode: InsertMode.insertOrIgnore,
);
}
}
@@ -204,7 +204,7 @@ class MatchDao extends DatabaseAccessor<AppDatabase> with _$MatchDaoMixin {
playerId: m.id,
groupId: match.group!.id,
),
mode: InsertMode.insertOrReplace,
mode: InsertMode.insertOrIgnore,
);
}
}
@@ -221,7 +221,7 @@ class MatchDao extends DatabaseAccessor<AppDatabase> with _$MatchDaoMixin {
matchId: match.id,
groupId: match.group!.id,
),
mode: InsertMode.insertOrReplace,
mode: InsertMode.insertOrIgnore,
);
}
}

View File

@@ -18,7 +18,7 @@ class PlayerMatchDao extends DatabaseAccessor<AppDatabase>
}) async {
await into(playerMatchTable).insert(
PlayerMatchTableCompanion.insert(playerId: playerId, matchId: matchId),
mode: InsertMode.insertOrReplace,
mode: InsertMode.insertOrIgnore,
);
}
@@ -121,7 +121,7 @@ class PlayerMatchDao extends DatabaseAccessor<AppDatabase>
inserts.map(
(c) => into(
playerMatchTable,
).insert(c, mode: InsertMode.insertOrReplace),
).insert(c, mode: InsertMode.insertOrIgnore),
),
);
}