From f4a278030ff1a821eefad4cf56ad1f84f442709e Mon Sep 17 00:00:00 2001 From: philipp Date: Fri, 10 Nov 2023 16:55:57 +0100 Subject: [PATCH] fix --- src/model/logbook.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/model/logbook.rs b/src/model/logbook.rs index b856afa..21913c3 100644 --- a/src/model/logbook.rs +++ b/src/model/logbook.rs @@ -145,6 +145,20 @@ impl From for LogbookCreateError { } impl Logbook { + pub async fn find_by_id_tx(db: &mut Transaction<'_, Sqlite>, id: i32) -> Option { + sqlx::query_as!( + Self, + " + SELECT id,boat_id,shipmaster,steering_person,shipmaster_only_steering,departure,arrival,destination,distance_in_km,comments,logtype + FROM logbook + WHERE id like ? + ", + id + ) + .fetch_one(db) + .await + .ok() + } pub async fn find_by_id(db: &SqlitePool, id: i32) -> Option { sqlx::query_as!( Self, @@ -273,7 +287,9 @@ ORDER BY departure DESC .fetch_one(&mut tx) .await.unwrap().id; - let logbook = Logbook::find_by_id(db, inserted_row as i32).await.unwrap(); //ok + let logbook = Logbook::find_by_id_tx(&mut tx, inserted_row as i32) + .await + .unwrap(); //ok return match logbook .home_with_transaction(&mut tx, created_by_user, log_to_finalize)