Skip to content

Commit

Permalink
Merge pull request #13 from samudradev/lifecycle
Browse files Browse the repository at this point in the history
🚑 HOTFIX: Proper compilation
  • Loading branch information
Thaza-Kun authored Sep 13, 2024
2 parents 05b5532 + 8effd18 commit 5e50b76
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion backend/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion backend/database/src/states.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,12 @@ impl Connection<sqlx::Sqlite> {
.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"),
}
}
}
}
Expand Down
13 changes: 8 additions & 5 deletions backend/database/src/views.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<Self::SOURCE>,
pool: &sqlx::Pool<<Self as crate::io::interface::View>::SOURCE>,
) -> sqlx::Result<Vec<Self>> {
sqlx::query_file_as!(
Self,
Expand All @@ -74,7 +75,9 @@ impl LemmaWithKonsepView {
}

/// Query all lemmas.
pub async fn query_all(pool: &sqlx::Pool<Self::SOURCE>) -> sqlx::Result<Vec<Self>> {
pub async fn query_all(
pool: &sqlx::Pool<<Self as crate::io::interface::View>::SOURCE>,
) -> sqlx::Result<Vec<Self>> {
// TODO: Might be a good idea to add limit
// TODO: And maybe sort by reverse chronology
sqlx::query_file_as!(
Expand Down

0 comments on commit 5e50b76

Please sign in to comment.