fix(data): race-safe DB open, graceful unknown types, explicit id error + fallback tests
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -4,10 +4,10 @@ import '../dto/pokemon_dto.dart';
|
||||
|
||||
/// Accès SQLite local au Pokédex. Schéma et migrations identiques à l'ancien PokedexDatabase.
|
||||
class PokemonLocalDataSource {
|
||||
Database? _database;
|
||||
Future<Database>? _dbFuture;
|
||||
|
||||
Future<Database> _getDb() async {
|
||||
_database ??= await openDatabase(
|
||||
Future<Database> _getDb() {
|
||||
return _dbFuture ??= openDatabase(
|
||||
'pokedex.db',
|
||||
version: 2,
|
||||
onUpgrade: (db, oldVersion, newVersion) async {
|
||||
@@ -22,7 +22,6 @@ class PokemonLocalDataSource {
|
||||
'CREATE TABLE IF NOT EXISTS pokemon (id INTEGER PRIMARY KEY NOT NULL, name TEXT NOT NULL, type1 TEXT NOT NULL, type2 TEXT, hp INTEGER NOT NULL, atk INTEGER NOT NULL, def INTEGER NOT NULL, spd INTEGER NOT NULL, description TEXT, isCaught INTEGER NOT NULL DEFAULT 0, isSeen INTEGER NOT NULL DEFAULT 0)');
|
||||
},
|
||||
);
|
||||
return _database!;
|
||||
}
|
||||
|
||||
Future<List<Pokemon>> getAll() async {
|
||||
|
||||
Reference in New Issue
Block a user