From 63cbf30dd7c3975e88dc03f27c99909b3b8bf3dd Mon Sep 17 00:00:00 2001 From: Valentin Tolmer Date: Fri, 10 Feb 2023 12:32:41 +0100 Subject: [PATCH] server: upgrade sea-orm to 0.11 --- Cargo.lock | 43 +++++-------------- server/Cargo.toml | 6 +-- server/src/domain/model/users.rs | 6 +-- .../src/domain/sql_group_backend_handler.rs | 2 +- server/src/domain/sql_migrations.rs | 6 ++- server/src/domain/sql_tables.rs | 7 ++- server/src/domain/sql_user_backend_handler.rs | 3 +- server/src/domain/types.rs | 21 +++++---- server/src/infra/jwt_sql_tables.rs | 6 ++- server/src/infra/sql_backend_handler.rs | 6 +-- 10 files changed, 43 insertions(+), 63 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1e0067b..56eb8f9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -855,21 +855,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crc" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53757d12b596c16c78b83458d732a5d1a17ab3f53f2f7412f6fb57cc8a140ab3" -dependencies = [ - "crc-catalog", -] - -[[package]] -name = "crc-catalog" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d0165d2900ae6778e36e80bbc4da3b5eefccee9ba939761f9c2882a5d9af3ff" - [[package]] name = "crc32fast" version = "1.3.2" @@ -2332,7 +2317,6 @@ dependencies = [ "rustls 0.20.6", "rustls-pemfile", "sea-orm", - "sea-query", "secstr", "serde", "serde_bytes", @@ -3428,15 +3412,14 @@ dependencies = [ [[package]] name = "sea-orm" -version = "0.10.7" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88694d01b528a94f90ad87f8d2f546d060d070eee180315c67d158cb69476034" +checksum = "e7a0e3ec90718d849c73b167df7a476672b64c7ee5f3c582179069e63b2451e1" dependencies = [ "async-stream", "async-trait", "chrono", "futures", - "futures-util", "log", "ouroboros", "sea-orm-macros", @@ -3453,9 +3436,9 @@ dependencies = [ [[package]] name = "sea-orm-macros" -version = "0.10.7" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7216195de9c6b2474fd0efab486173dccd0eff21f28cc54aa4c0205d52fb3af0" +checksum = "5d89f7d4d2533c178e08a9e1990619c391e9ca7b402851d02a605938b15e03d9" dependencies = [ "bae", "heck 0.3.3", @@ -3466,9 +3449,9 @@ dependencies = [ [[package]] name = "sea-query" -version = "0.27.2" +version = "0.28.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4f0fc4d8e44e1d51c739a68d336252a18bc59553778075d5e32649be6ec92ed" +checksum = "d2fbe015dbdaa7d8829d71c1e14fb6289e928ac256b93dfda543c85cd89d6f03" dependencies = [ "chrono", "sea-query-derive", @@ -3477,9 +3460,9 @@ dependencies = [ [[package]] name = "sea-query-binder" -version = "0.2.2" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c2585b89c985cfacfe0ec9fc9e7bb055b776c1a2581c4e3c6185af2b8bf8865" +checksum = "03548c63aec07afd4fd190923e0160d2f2fc92def27470b54154cf232da6203b" dependencies = [ "chrono", "sea-query", @@ -3489,11 +3472,11 @@ dependencies = [ [[package]] name = "sea-query-derive" -version = "0.2.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34cdc022b4f606353fe5dc85b09713a04e433323b70163e81513b141c6ae6eb5" +checksum = "63f62030c60f3a691f5fe251713b4e220b306e50a71e1d6f9cce1f24bb781978" dependencies = [ - "heck 0.3.3", + "heck 0.4.0", "proc-macro2", "quote", "syn", @@ -3827,7 +3810,6 @@ dependencies = [ "byteorder", "bytes", "chrono", - "crc", "crossbeam-queue", "digest 0.10.6", "dirs", @@ -3888,7 +3870,6 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "sha2 0.10.6", "sqlx-core", "sqlx-rt", "syn", @@ -4508,9 +4489,7 @@ version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "422ee0de9031b5b948b97a8fc04e3aa35230001a722ddd27943e0be31564ce4c" dependencies = [ - "getrandom 0.2.7", "md-5", - "serde", ] [[package]] diff --git a/server/Cargo.toml b/server/Cargo.toml index 40f69dc..04d212f 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -72,10 +72,6 @@ version = "0.10.1" [dependencies.lldap_auth] path = "../auth" -[dependencies.sea-query] -version = "*" -features = ["with-chrono"] - [dependencies.opaque-ke] version = "0.6" @@ -109,7 +105,7 @@ default-features = false version = "0.24" [dependencies.sea-orm] -version= ">=0.10.7" +version= "0.11" default-features = false features = ["macros", "with-chrono", "with-uuid", "sqlx-all", "runtime-actix-rustls"] diff --git a/server/src/domain/model/users.rs b/server/src/domain/model/users.rs index 32f8d86..84b583a 100644 --- a/server/src/domain/model/users.rs +++ b/server/src/domain/model/users.rs @@ -1,6 +1,6 @@ //! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.3 -use sea_orm::entity::prelude::*; +use sea_orm::{entity::prelude::*, sea_query::BlobSize}; use serde::{Deserialize, Serialize}; use crate::domain::types::{JpegPhoto, UserId, Uuid}; @@ -56,9 +56,9 @@ impl ColumnTrait for Column { Column::DisplayName => ColumnType::String(Some(255)), Column::FirstName => ColumnType::String(Some(255)), Column::LastName => ColumnType::String(Some(255)), - Column::Avatar => ColumnType::Binary, + Column::Avatar => ColumnType::Binary(BlobSize::Long), Column::CreationDate => ColumnType::DateTime, - Column::PasswordHash => ColumnType::Binary, + Column::PasswordHash => ColumnType::Binary(BlobSize::Medium), Column::TotpSecret => ColumnType::String(Some(64)), Column::MfaType => ColumnType::String(Some(64)), Column::Uuid => ColumnType::String(Some(36)), diff --git a/server/src/domain/sql_group_backend_handler.rs b/server/src/domain/sql_group_backend_handler.rs index 5367090..e5677a4 100644 --- a/server/src/domain/sql_group_backend_handler.rs +++ b/server/src/domain/sql_group_backend_handler.rs @@ -7,10 +7,10 @@ use crate::domain::{ }; use async_trait::async_trait; use sea_orm::{ + sea_query::{Cond, IntoCondition, SimpleExpr}, ActiveModelTrait, ActiveValue, ColumnTrait, EntityTrait, QueryFilter, QueryOrder, QuerySelect, QueryTrait, }; -use sea_query::{Cond, IntoCondition, SimpleExpr}; use tracing::{debug, instrument}; fn get_group_filter_expr(filter: GroupRequestFilter) -> Cond { diff --git a/server/src/domain/sql_migrations.rs b/server/src/domain/sql_migrations.rs index deb82c7..7be7b7f 100644 --- a/server/src/domain/sql_migrations.rs +++ b/server/src/domain/sql_migrations.rs @@ -2,8 +2,10 @@ use crate::domain::{ sql_tables::{DbConnection, SchemaVersion}, types::{GroupId, UserId, Uuid}, }; -use sea_orm::{ConnectionTrait, FromQueryResult, Statement, TransactionTrait}; -use sea_query::{ColumnDef, Expr, ForeignKey, ForeignKeyAction, Iden, Query, Table, Value}; +use sea_orm::{ + sea_query::{self, ColumnDef, Expr, ForeignKey, ForeignKeyAction, Query, Table, Value}, + ConnectionTrait, FromQueryResult, Iden, Statement, TransactionTrait, +}; use serde::{Deserialize, Serialize}; use tracing::{info, instrument, warn}; diff --git a/server/src/domain/sql_tables.rs b/server/src/domain/sql_tables.rs index 0a81363..b61fd93 100644 --- a/server/src/domain/sql_tables.rs +++ b/server/src/domain/sql_tables.rs @@ -7,12 +7,11 @@ pub type DbConnection = sea_orm::DatabaseConnection; pub struct SchemaVersion(pub i16); impl sea_orm::TryGetable for SchemaVersion { - fn try_get( + fn try_get_by( res: &sea_orm::QueryResult, - pre: &str, - col: &str, + index: I, ) -> Result { - Ok(SchemaVersion(i16::try_get(res, pre, col)?)) + Ok(SchemaVersion(i16::try_get_by(res, index)?)) } } diff --git a/server/src/domain/sql_user_backend_handler.rs b/server/src/domain/sql_user_backend_handler.rs index 9220dff..a481565 100644 --- a/server/src/domain/sql_user_backend_handler.rs +++ b/server/src/domain/sql_user_backend_handler.rs @@ -8,11 +8,10 @@ use super::{ use async_trait::async_trait; use sea_orm::{ entity::IntoActiveValue, - sea_query::{Cond, Expr, IntoCondition, SimpleExpr}, + sea_query::{Alias, Cond, Expr, IntoColumnRef, IntoCondition, SimpleExpr}, ActiveModelTrait, ActiveValue, ColumnTrait, EntityTrait, ModelTrait, QueryFilter, QueryOrder, QuerySelect, QueryTrait, Set, }; -use sea_query::{Alias, IntoColumnRef}; use std::collections::HashSet; use tracing::{debug, instrument}; diff --git a/server/src/domain/types.rs b/server/src/domain/types.rs index 494f8f9..99ee6f4 100644 --- a/server/src/domain/types.rs +++ b/server/src/domain/types.rs @@ -53,8 +53,11 @@ impl std::string::ToString for Uuid { } impl TryGetable for Uuid { - fn try_get(res: &QueryResult, pre: &str, col: &str) -> std::result::Result { - Ok(Uuid(String::try_get(res, pre, col)?)) + fn try_get_by( + res: &QueryResult, + index: I, + ) -> std::result::Result { + Ok(Uuid(String::try_get_by(res, index)?)) } } @@ -142,8 +145,8 @@ impl From<&UserId> for Value { } impl TryGetable for UserId { - fn try_get(res: &QueryResult, pre: &str, col: &str) -> Result { - Ok(UserId::new(&String::try_get(res, pre, col)?)) + fn try_get_by(res: &QueryResult, index: I) -> Result { + Ok(UserId::new(&String::try_get_by(res, index)?)) } } @@ -261,8 +264,8 @@ impl JpegPhoto { } impl TryGetable for JpegPhoto { - fn try_get(res: &QueryResult, pre: &str, col: &str) -> Result { - >>::try_from(Vec::::try_get(res, pre, col)?) + fn try_get_by(res: &QueryResult, index: I) -> Result { + >>::try_from(Vec::::try_get_by(res, index)?) .map_err(|e| { TryGetError::DbErr(DbErr::TryIntoErr { from: "[u8]", @@ -345,8 +348,8 @@ impl From for Value { } impl TryGetable for GroupId { - fn try_get(res: &QueryResult, pre: &str, col: &str) -> Result { - Ok(GroupId(i32::try_get(res, pre, col)?)) + fn try_get_by(res: &QueryResult, index: I) -> Result { + Ok(GroupId(i32::try_get_by(res, index)?)) } } @@ -364,7 +367,7 @@ impl ValueType for GroupId { } fn column_type() -> ColumnType { - ColumnType::Integer(None) + ColumnType::Integer } } diff --git a/server/src/infra/jwt_sql_tables.rs b/server/src/infra/jwt_sql_tables.rs index b3443c6..2998235 100644 --- a/server/src/infra/jwt_sql_tables.rs +++ b/server/src/infra/jwt_sql_tables.rs @@ -1,5 +1,7 @@ -use sea_orm::ConnectionTrait; -use sea_query::{ColumnDef, ForeignKey, ForeignKeyAction, Iden, Table}; +use sea_orm::{ + sea_query::{self, ColumnDef, ForeignKey, ForeignKeyAction, Iden, Table}, + ConnectionTrait, +}; pub use crate::domain::{sql_migrations::Users, sql_tables::DbConnection}; diff --git a/server/src/infra/sql_backend_handler.rs b/server/src/infra/sql_backend_handler.rs index 253eca8..16e3f1a 100644 --- a/server/src/infra/sql_backend_handler.rs +++ b/server/src/infra/sql_backend_handler.rs @@ -7,10 +7,10 @@ use crate::domain::{ }; use async_trait::async_trait; use sea_orm::{ - sea_query::Cond, ActiveModelTrait, ColumnTrait, EntityTrait, FromQueryResult, IntoActiveModel, - QueryFilter, QuerySelect, + sea_query::{Cond, Expr}, + ActiveModelTrait, ColumnTrait, EntityTrait, FromQueryResult, IntoActiveModel, QueryFilter, + QuerySelect, }; -use sea_query::Expr; use std::collections::HashSet; use tracing::{debug, instrument};