diff --git a/Cargo.toml b/Cargo.toml index 9130a6d..be9728a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ http = "*" ldap3_server = "*" log = "*" serde = "*" -sqlx = { version = "0.5", features = [ "runtime-actix-native-tls", "any", "sqlite", "mysql", "postgres", "macros" ] } +sqlx = { version = "0.5", features = [ "runtime-actix-native-tls", "any", "sqlite", "mysql", "postgres", "macros" , "chrono"] } thiserror = "*" tokio = { version = "1.2.0", features = ["full"] } tokio-util = "0.6.3" diff --git a/src/domain/handler.rs b/src/domain/handler.rs index 5bb0bbc..ab1bad3 100644 --- a/src/domain/handler.rs +++ b/src/domain/handler.rs @@ -3,7 +3,7 @@ use crate::infra::configuration::Configuration; use anyhow::{bail, Result}; use async_trait::async_trait; use futures_util::StreamExt; -use sea_query::{Expr, MysqlQueryBuilder, Query, SimpleExpr}; +use sea_query::{Expr, SqliteQueryBuilder, Query, SimpleExpr}; use sqlx::Row; use crate::domain::sql_tables::Pool; @@ -36,8 +36,7 @@ pub struct User { pub first_name: String, pub last_name: String, // pub avatar: ?, - // TODO: wait until supported for Any - // pub creation_date: chrono::NaiveDateTime, + pub creation_date: chrono::NaiveDateTime, } #[async_trait] @@ -97,7 +96,7 @@ impl BackendHandler for SqlBackendHandler { .column(Users::Password) .from(Users::Table) .and_where(Expr::col(Users::UserId).eq(request.name.as_str())) - .to_string(MysqlQueryBuilder); + .to_string(SqliteQueryBuilder); if let Ok(row) = sqlx::query(&query).fetch_one(&self.sql_pool).await { if passwords_match(&request.password, &row.get::("password")) { return Ok(()); @@ -126,7 +125,7 @@ impl BackendHandler for SqlBackendHandler { } } - query_builder.to_string(MysqlQueryBuilder) + query_builder.to_string(SqliteQueryBuilder) }; let results = sqlx::query_as::<_, User>(&query) diff --git a/src/domain/sql_tables.rs b/src/domain/sql_tables.rs index e1db5c1..14e9040 100644 --- a/src/domain/sql_tables.rs +++ b/src/domain/sql_tables.rs @@ -1,7 +1,7 @@ use sea_query::*; -pub type Pool = sqlx::any::AnyPool; -pub type PoolOptions = sqlx::any::AnyPoolOptions; +pub type Pool = sqlx::sqlite::SqlitePool; +pub type PoolOptions = sqlx::sqlite::SqlitePoolOptions; #[derive(Iden)] pub enum Users { diff --git a/src/infra/ldap_handler.rs b/src/infra/ldap_handler.rs index 693e77a..b7804e7 100644 --- a/src/infra/ldap_handler.rs +++ b/src/infra/ldap_handler.rs @@ -358,6 +358,7 @@ mod tests { display_name: "Bôb Böbberson".to_string(), first_name: "Bôb".to_string(), last_name: "Böbberson".to_string(), + creation_date: NaiveDateTime::from_timestamp(1_000_000, 0), }, User { user_id: "jim".to_string(), @@ -365,6 +366,7 @@ mod tests { display_name: "Jimminy Cricket".to_string(), first_name: "Jim".to_string(), last_name: "Cricket".to_string(), + creation_date: NaiveDateTime::from_timestamp(1_500_000, 0), }, ]) });