Skip to content

Commit

Permalink
Update diesel and diesel-async.
Browse files Browse the repository at this point in the history
  • Loading branch information
kaj committed Jul 31, 2024
1 parent e0e37c3 commit 46bc418
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ The format is based on
## Unreleased

* Improved item (image) sizing css. I hope it works in safari.
* Updated to `diesel` 2.1.0, `diesel-async` 0.3.2, `brotli` to 6.0.0,
* Updated to `diesel` 2.2.2, `diesel-async` 0.5.0, `brotli` to 6.0.0,
and `ructe` 0.17.0.
* Uses std LazyLock (require rust 1.80) instead of `lazy_regex`.
* Removed unneded db model structs.
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ async-walkdir = "0.2.0"
brotli = "6.0.0"
chrono = "0.4.19" # Must match version used by diesel
clap = { version = "4.0.18", features = ["derive", "wrap_help", "env"] }
diesel-async = { version = "0.3.0", features = ["deadpool", "postgres"] }
diesel-async = { version = "0.5.0", features = ["deadpool", "postgres"] }
dotenv = "0.15"
flate2 = "1.0.14"
futures-lite = "1.12.0"
Expand Down Expand Up @@ -44,7 +44,7 @@ version = "1.1.1"
[dependencies.diesel]
default-features = false
features = ["chrono", "postgres"]
version = "2.1.0"
version = "2.2.2"

[dependencies.warp]
default-features = false
Expand Down
2 changes: 1 addition & 1 deletion src/adm/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use diesel::prelude::*;
use diesel::sql_types::{Nullable, Timestamp};
use diesel_async::{AsyncPgConnection, RunQueryDsl};

sql_function! {
define_sql_function! {
#[aggregate]
fn year_of_timestamp(date: Nullable<Timestamp>) -> Nullable<SmallInt>
}
Expand Down
4 changes: 2 additions & 2 deletions src/server/autocomplete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ mod tests {
}
}

sql_function!(fn lower(string: Text) -> Text);
sql_function!(fn strpos(string: Text, substring: Text) -> Integer);
define_sql_function!(fn lower(string: Text) -> Text);
define_sql_function!(fn strpos(string: Text, substring: Text) -> Integer);

type NameSlugScore = (String, String, i32);

Expand Down
2 changes: 1 addition & 1 deletion src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ async fn static_file(name: Tail) -> Result<Response> {
}

async fn random_image(context: Context) -> Result<Response> {
sql_function! { fn random() -> Integer };
define_sql_function! { fn random() -> Integer };

let photo = Photo::query(context.is_authorized())
.select(p::id)
Expand Down
15 changes: 7 additions & 8 deletions src/server/views_by_date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,30 +77,29 @@ pub fn routes(s: ContextFilter) -> BoxedFilter<(Response,)> {
.boxed()
}

sql_function! {
define_sql_function! {
#[aggregate]
fn year_of_timestamp(date: Nullable<Timestamp>) -> Nullable<SmallInt>
}
sql_function! {
define_sql_function! {
#[aggregate]
fn month_of_timestamp(date: Nullable<Timestamp>) -> Nullable<SmallInt>
}
sql_function! {
define_sql_function! {
#[aggregate]
fn day_of_timestamp(date: Nullable<Timestamp>) -> Nullable<SmallInt>
}

mod filter {
use diesel::sql_function;
use diesel::sql_types::{Nullable, Timestamp};
use diesel::{define_sql_function, sql_types::{Nullable, Timestamp}};

sql_function! {
define_sql_function! {
fn year_of_timestamp(date: Nullable<Timestamp>) -> Nullable<SmallInt>
}
sql_function! {
define_sql_function! {
fn month_of_timestamp(date: Nullable<Timestamp>) -> Nullable<SmallInt>
}
sql_function! {
define_sql_function! {
fn day_of_timestamp(date: Nullable<Timestamp>) -> Nullable<SmallInt>
}
}
Expand Down

0 comments on commit 46bc418

Please sign in to comment.