From 1ce52d7180679f9afcff42500b4347f679ad013c Mon Sep 17 00:00:00 2001 From: Thaza_Kun <61819672+Thaza-Kun@users.noreply.github.com> Date: Fri, 13 Sep 2024 23:30:07 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E2=9A=99=20FIX:=20Avoid=20recursion=20+=20?= =?UTF-8?q?syntax=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/database/src/states.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/backend/database/src/states.rs b/backend/database/src/states.rs index 614109a..6002ec7 100644 --- a/backend/database/src/states.rs +++ b/backend/database/src/states.rs @@ -101,7 +101,12 @@ impl Connection { .populate_with_presets() .await .unwrap(); - Connection::from(url).await + // We assume only happy path after this + Self { + pool: sqlx::SqlitePool::connect(&url) + .await + .expect("Recursive solution required if this error happened"), + } } } } @@ -113,7 +118,7 @@ impl Connection { #[doc = include_str!("../transactions/sqlite/count_items.sql")] /// ``` pub async fn statistics(self) -> Result> { - sqlx::query_as!(Counts, "transactions/sqlite/count_items.sql") + sqlx::query_file_as!(Counts, "transactions/sqlite/count_items.sql") .fetch_one(&self.pool) .await .map_err(BackendError::from) From 69d02474738575c7037261f1a7da5fb7da602407 Mon Sep 17 00:00:00 2001 From: Thaza_Kun <61819672+Thaza-Kun@users.noreply.github.com> Date: Sat, 14 Sep 2024 00:55:16 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=9A=A9=20Compile=20feature=20function?= =?UTF-8?q?ality=20properly?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/database/src/views.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/backend/database/src/views.rs b/backend/database/src/views.rs index 270b557..fbbbfcd 100644 --- a/backend/database/src/views.rs +++ b/backend/database/src/views.rs @@ -7,7 +7,7 @@ use itertools::Itertools; use crate::data::items::konsep::KonsepHashMap; use crate::io::interface::IntoViewMap; -/// A [View] whose query joins konsep to its tags (cakupan, kata_asing) +/// A [View](crate::io::interface::View) whose query joins konsep to its tags (cakupan, kata_asing) /// /// Running this command: /// ```no_run @@ -55,14 +55,15 @@ impl crate::io::interface::View for LemmaWithKonsepView { impl crate::io::interface::View for LemmaWithKonsepView { type SOURCE = sqlx::Postgres; } +#[cfg(all(feature = "sqlite", feature = "postgres"))] +compile_error!("The code as it is currently designed results in conflicting implementations from features `sqlite` and `postgres`. TODO: FIX"); -#[cfg(feature = "sqlite")] -#[cfg(feature = "postgres")] +#[cfg(any(feature = "sqlite", feature = "postgres"))] impl LemmaWithKonsepView { /// Query a single lemma with its associated konseps and attachments. pub async fn query_lemma( lemma: String, - pool: &sqlx::Pool, + pool: &sqlx::Pool<::SOURCE>, ) -> sqlx::Result> { sqlx::query_file_as!( Self, @@ -74,7 +75,9 @@ impl LemmaWithKonsepView { } /// Query all lemmas. - pub async fn query_all(pool: &sqlx::Pool) -> sqlx::Result> { + pub async fn query_all( + pool: &sqlx::Pool<::SOURCE>, + ) -> sqlx::Result> { // TODO: Might be a good idea to add limit // TODO: And maybe sort by reverse chronology sqlx::query_file_as!( From 8effd18f3c552b6b03a653d00345b32ccf19f1d5 Mon Sep 17 00:00:00 2001 From: Thaza_Kun <61819672+Thaza-Kun@users.noreply.github.com> Date: Sat, 14 Sep 2024 00:56:58 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=9A=80=20BUMP:=20Patch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/Cargo.lock | 2 +- backend/database/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/Cargo.lock b/backend/Cargo.lock index 9a23381..534fa79 100644 --- a/backend/Cargo.lock +++ b/backend/Cargo.lock @@ -659,7 +659,7 @@ dependencies = [ [[package]] name = "database" -version = "0.5.1" +version = "0.5.2" dependencies = [ "async-trait", "chrono", diff --git a/backend/database/Cargo.toml b/backend/database/Cargo.toml index beebb98..4287d8e 100644 --- a/backend/database/Cargo.toml +++ b/backend/database/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "database" -version = "0.5.1" +version = "0.5.2" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html