Skip to content

Commit

Permalink
chore: Drop deprecated sql_function! in favour of `define_sql_funct…
Browse files Browse the repository at this point in the history
…ion!`
  • Loading branch information
phildenhoff committed Oct 29, 2024
1 parent 295eeda commit 71838b2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src-tauri/libcalibre/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ edition = "2021"

[dependencies]
chrono = { version = "0.4.31", features = ["serde"] }
diesel = { version = "2.1.0", features = ["sqlite", "chrono", "returning_clauses_for_sqlite_3_35"] }
diesel_migrations = { version = "2.1.0", features = ["sqlite"] }
diesel = { version = "2.2.4", features = ["sqlite", "chrono", "returning_clauses_for_sqlite_3_35"] }
diesel_migrations = { version = "2.2.0", features = ["sqlite"] }
epub = "2.1.1"
mobi = "0.8.0"
regex = "1.10.2"
Expand Down
8 changes: 4 additions & 4 deletions src-tauri/libcalibre/src/persistence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ pub fn sort_book_title(title: String) -> String {
pub fn establish_connection(db_path: &str) -> Result<diesel::SqliteConnection, ()> {
// Setup custom SQL functions. Required because Calibre does this.
// See: https://github.com/kovidgoyal/calibre/blob/7f3ccb333d906f5867636dd0dc4700b495e5ae6f/src/calibre/library/database.py#L55-L70
sql_function!(fn title_sort(title: Text) -> Text);
sql_function!(fn uuid4() -> Text);
define_sql_function!(fn title_sort(title: Text) -> Text);
define_sql_function!(fn uuid4() -> Text);

let mut connection = diesel::SqliteConnection::establish(db_path).or(Err(()))?;

// Register SQL function implementations. Ignore any errors.
let _ = title_sort::register_impl(&mut connection, sort_book_title);
let _ = uuid4::register_impl(&connection, || uuid::Uuid::new_v4().to_string());
let _ = title_sort_utils::register_impl(&mut connection, sort_book_title);
let _ = uuid4_utils::register_impl(&connection, || uuid::Uuid::new_v4().to_string());

Ok(connection)
}

0 comments on commit 71838b2

Please sign in to comment.