From 897704fab3fb1ba2204f7959b7db498555b98dac Mon Sep 17 00:00:00 2001 From: Valentin Tolmer Date: Mon, 1 Aug 2022 08:35:44 +0200 Subject: [PATCH] server: Fix extra error message when DB doesn't exist Fixes #270 --- server/src/domain/sql_tables.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/server/src/domain/sql_tables.rs b/server/src/domain/sql_tables.rs index d7f7ca9..989e604 100644 --- a/server/src/domain/sql_tables.rs +++ b/server/src/domain/sql_tables.rs @@ -77,11 +77,10 @@ async fn column_exists(pool: &Pool, table_name: &str, column_name: &str) -> sqlx "SELECT COUNT(*) AS col_count FROM pragma_table_info('{}') WHERE name = '{}'", table_name, column_name ); - Ok(sqlx::query(&query) - .fetch_one(pool) - .await? - .get::("col_count") - > 0) + match sqlx::query(&query).fetch_one(pool).await { + Err(_) => Ok(false), + Ok(row) => Ok(row.get::("col_count") > 0), + } } pub async fn create_group(group_name: &str, pool: &Pool) -> sqlx::Result<()> {