From 32d847308695f00e8193fbcb0750806591e6aa54 Mon Sep 17 00:00:00 2001 From: fbachus Date: Wed, 22 Jul 2026 02:59:14 +0200 Subject: [PATCH] feat(transport_helper): add conflictAlgorithm to db inserts this way we can try to persist data at liberty without risking failure right now, redundant entries will be ignored and updates have to happen with update nothing calls dbUpdate yet --- lib/transport_helper.dart | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/lib/transport_helper.dart b/lib/transport_helper.dart index 955e090..2289b73 100644 --- a/lib/transport_helper.dart +++ b/lib/transport_helper.dart @@ -409,7 +409,11 @@ class Segment { void dbInsert() async { Database database = DbHelper.db; - id = await database.insert(tableName, toMap()); + id = await database.insert( + tableName, + toMap(), + conflictAlgorithm: ConflictAlgorithm.ignore, + ); } void dbUpdate() async { @@ -532,7 +536,11 @@ class Station { void dbInsert() async { Database database = DbHelper.db; - database.insert(tableName, _toMap()); + database.insert( + tableName, + _toMap(), + conflictAlgorithm: ConflictAlgorithm.ignore, + ); } void _dbInsertStationLines() async { @@ -636,7 +644,11 @@ class Vehicle { void dbInsert() async { Database database = DbHelper.db; - database.insert(tableName, _toMap()); + database.insert( + tableName, + _toMap(), + conflictAlgorithm: ConflictAlgorithm.ignore, + ); } void dbUpdate() async { @@ -740,7 +752,11 @@ class Line { void dbInsert() async { Database database = DbHelper.db; - database.insert(tableName, _toMap()); + database.insert( + tableName, + _toMap(), + conflictAlgorithm: ConflictAlgorithm.ignore, + ); } void dbUpdate() async { @@ -802,7 +818,7 @@ class Departure { factory Departure.fromJson(Map json) { Vehicle vehicle = Vehicle.fromJson(json["Product"][0]); // try { - // vehicle.dbInsert(); + vehicle.dbInsert(); // } catch (e) { // vehicle.dbUpdate(); // } @@ -812,7 +828,7 @@ class Departure { transportLines: [], ); // try { - // station.dbInsert(); + station.dbInsert(); // } catch (e) { // station.dbUpdate(); // } @@ -907,7 +923,11 @@ class Departure { void dbInsert() async { Database database = DbHelper.db; - id = await database.insert(tableName, _toMap()); + id = await database.insert( + tableName, + _toMap(), + conflictAlgorithm: ConflictAlgorithm.ignore, + ); } void dbUpdate() async {