server: upgrade sea-orm to 0.11

This commit is contained in:
Valentin Tolmer 2023-02-10 12:32:41 +01:00 committed by nitnelave
parent 96eb17a963
commit 63cbf30dd7
10 changed files with 43 additions and 63 deletions

43
Cargo.lock generated
View File

@ -855,21 +855,6 @@ dependencies = [
"libc", "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]] [[package]]
name = "crc32fast" name = "crc32fast"
version = "1.3.2" version = "1.3.2"
@ -2332,7 +2317,6 @@ dependencies = [
"rustls 0.20.6", "rustls 0.20.6",
"rustls-pemfile", "rustls-pemfile",
"sea-orm", "sea-orm",
"sea-query",
"secstr", "secstr",
"serde", "serde",
"serde_bytes", "serde_bytes",
@ -3428,15 +3412,14 @@ dependencies = [
[[package]] [[package]]
name = "sea-orm" name = "sea-orm"
version = "0.10.7" version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "88694d01b528a94f90ad87f8d2f546d060d070eee180315c67d158cb69476034" checksum = "e7a0e3ec90718d849c73b167df7a476672b64c7ee5f3c582179069e63b2451e1"
dependencies = [ dependencies = [
"async-stream", "async-stream",
"async-trait", "async-trait",
"chrono", "chrono",
"futures", "futures",
"futures-util",
"log", "log",
"ouroboros", "ouroboros",
"sea-orm-macros", "sea-orm-macros",
@ -3453,9 +3436,9 @@ dependencies = [
[[package]] [[package]]
name = "sea-orm-macros" name = "sea-orm-macros"
version = "0.10.7" version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7216195de9c6b2474fd0efab486173dccd0eff21f28cc54aa4c0205d52fb3af0" checksum = "5d89f7d4d2533c178e08a9e1990619c391e9ca7b402851d02a605938b15e03d9"
dependencies = [ dependencies = [
"bae", "bae",
"heck 0.3.3", "heck 0.3.3",
@ -3466,9 +3449,9 @@ dependencies = [
[[package]] [[package]]
name = "sea-query" name = "sea-query"
version = "0.27.2" version = "0.28.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4f0fc4d8e44e1d51c739a68d336252a18bc59553778075d5e32649be6ec92ed" checksum = "d2fbe015dbdaa7d8829d71c1e14fb6289e928ac256b93dfda543c85cd89d6f03"
dependencies = [ dependencies = [
"chrono", "chrono",
"sea-query-derive", "sea-query-derive",
@ -3477,9 +3460,9 @@ dependencies = [
[[package]] [[package]]
name = "sea-query-binder" name = "sea-query-binder"
version = "0.2.2" version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c2585b89c985cfacfe0ec9fc9e7bb055b776c1a2581c4e3c6185af2b8bf8865" checksum = "03548c63aec07afd4fd190923e0160d2f2fc92def27470b54154cf232da6203b"
dependencies = [ dependencies = [
"chrono", "chrono",
"sea-query", "sea-query",
@ -3489,11 +3472,11 @@ dependencies = [
[[package]] [[package]]
name = "sea-query-derive" name = "sea-query-derive"
version = "0.2.0" version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34cdc022b4f606353fe5dc85b09713a04e433323b70163e81513b141c6ae6eb5" checksum = "63f62030c60f3a691f5fe251713b4e220b306e50a71e1d6f9cce1f24bb781978"
dependencies = [ dependencies = [
"heck 0.3.3", "heck 0.4.0",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn", "syn",
@ -3827,7 +3810,6 @@ dependencies = [
"byteorder", "byteorder",
"bytes", "bytes",
"chrono", "chrono",
"crc",
"crossbeam-queue", "crossbeam-queue",
"digest 0.10.6", "digest 0.10.6",
"dirs", "dirs",
@ -3888,7 +3870,6 @@ dependencies = [
"once_cell", "once_cell",
"proc-macro2", "proc-macro2",
"quote", "quote",
"sha2 0.10.6",
"sqlx-core", "sqlx-core",
"sqlx-rt", "sqlx-rt",
"syn", "syn",
@ -4508,9 +4489,7 @@ version = "1.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "422ee0de9031b5b948b97a8fc04e3aa35230001a722ddd27943e0be31564ce4c" checksum = "422ee0de9031b5b948b97a8fc04e3aa35230001a722ddd27943e0be31564ce4c"
dependencies = [ dependencies = [
"getrandom 0.2.7",
"md-5", "md-5",
"serde",
] ]
[[package]] [[package]]

View File

@ -72,10 +72,6 @@ version = "0.10.1"
[dependencies.lldap_auth] [dependencies.lldap_auth]
path = "../auth" path = "../auth"
[dependencies.sea-query]
version = "*"
features = ["with-chrono"]
[dependencies.opaque-ke] [dependencies.opaque-ke]
version = "0.6" version = "0.6"
@ -109,7 +105,7 @@ default-features = false
version = "0.24" version = "0.24"
[dependencies.sea-orm] [dependencies.sea-orm]
version= ">=0.10.7" version= "0.11"
default-features = false default-features = false
features = ["macros", "with-chrono", "with-uuid", "sqlx-all", "runtime-actix-rustls"] features = ["macros", "with-chrono", "with-uuid", "sqlx-all", "runtime-actix-rustls"]

View File

@ -1,6 +1,6 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.3 //! `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 serde::{Deserialize, Serialize};
use crate::domain::types::{JpegPhoto, UserId, Uuid}; use crate::domain::types::{JpegPhoto, UserId, Uuid};
@ -56,9 +56,9 @@ impl ColumnTrait for Column {
Column::DisplayName => ColumnType::String(Some(255)), Column::DisplayName => ColumnType::String(Some(255)),
Column::FirstName => ColumnType::String(Some(255)), Column::FirstName => ColumnType::String(Some(255)),
Column::LastName => 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::CreationDate => ColumnType::DateTime,
Column::PasswordHash => ColumnType::Binary, Column::PasswordHash => ColumnType::Binary(BlobSize::Medium),
Column::TotpSecret => ColumnType::String(Some(64)), Column::TotpSecret => ColumnType::String(Some(64)),
Column::MfaType => ColumnType::String(Some(64)), Column::MfaType => ColumnType::String(Some(64)),
Column::Uuid => ColumnType::String(Some(36)), Column::Uuid => ColumnType::String(Some(36)),

View File

@ -7,10 +7,10 @@ use crate::domain::{
}; };
use async_trait::async_trait; use async_trait::async_trait;
use sea_orm::{ use sea_orm::{
sea_query::{Cond, IntoCondition, SimpleExpr},
ActiveModelTrait, ActiveValue, ColumnTrait, EntityTrait, QueryFilter, QueryOrder, QuerySelect, ActiveModelTrait, ActiveValue, ColumnTrait, EntityTrait, QueryFilter, QueryOrder, QuerySelect,
QueryTrait, QueryTrait,
}; };
use sea_query::{Cond, IntoCondition, SimpleExpr};
use tracing::{debug, instrument}; use tracing::{debug, instrument};
fn get_group_filter_expr(filter: GroupRequestFilter) -> Cond { fn get_group_filter_expr(filter: GroupRequestFilter) -> Cond {

View File

@ -2,8 +2,10 @@ use crate::domain::{
sql_tables::{DbConnection, SchemaVersion}, sql_tables::{DbConnection, SchemaVersion},
types::{GroupId, UserId, Uuid}, types::{GroupId, UserId, Uuid},
}; };
use sea_orm::{ConnectionTrait, FromQueryResult, Statement, TransactionTrait}; use sea_orm::{
use sea_query::{ColumnDef, Expr, ForeignKey, ForeignKeyAction, Iden, Query, Table, Value}; sea_query::{self, ColumnDef, Expr, ForeignKey, ForeignKeyAction, Query, Table, Value},
ConnectionTrait, FromQueryResult, Iden, Statement, TransactionTrait,
};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use tracing::{info, instrument, warn}; use tracing::{info, instrument, warn};

View File

@ -7,12 +7,11 @@ pub type DbConnection = sea_orm::DatabaseConnection;
pub struct SchemaVersion(pub i16); pub struct SchemaVersion(pub i16);
impl sea_orm::TryGetable for SchemaVersion { impl sea_orm::TryGetable for SchemaVersion {
fn try_get( fn try_get_by<I: sea_orm::ColIdx>(
res: &sea_orm::QueryResult, res: &sea_orm::QueryResult,
pre: &str, index: I,
col: &str,
) -> Result<Self, sea_orm::TryGetError> { ) -> Result<Self, sea_orm::TryGetError> {
Ok(SchemaVersion(i16::try_get(res, pre, col)?)) Ok(SchemaVersion(i16::try_get_by(res, index)?))
} }
} }

View File

@ -8,11 +8,10 @@ use super::{
use async_trait::async_trait; use async_trait::async_trait;
use sea_orm::{ use sea_orm::{
entity::IntoActiveValue, entity::IntoActiveValue,
sea_query::{Cond, Expr, IntoCondition, SimpleExpr}, sea_query::{Alias, Cond, Expr, IntoColumnRef, IntoCondition, SimpleExpr},
ActiveModelTrait, ActiveValue, ColumnTrait, EntityTrait, ModelTrait, QueryFilter, QueryOrder, ActiveModelTrait, ActiveValue, ColumnTrait, EntityTrait, ModelTrait, QueryFilter, QueryOrder,
QuerySelect, QueryTrait, Set, QuerySelect, QueryTrait, Set,
}; };
use sea_query::{Alias, IntoColumnRef};
use std::collections::HashSet; use std::collections::HashSet;
use tracing::{debug, instrument}; use tracing::{debug, instrument};

View File

@ -53,8 +53,11 @@ impl std::string::ToString for Uuid {
} }
impl TryGetable for Uuid { impl TryGetable for Uuid {
fn try_get(res: &QueryResult, pre: &str, col: &str) -> std::result::Result<Self, TryGetError> { fn try_get_by<I: sea_orm::ColIdx>(
Ok(Uuid(String::try_get(res, pre, col)?)) res: &QueryResult,
index: I,
) -> std::result::Result<Self, TryGetError> {
Ok(Uuid(String::try_get_by(res, index)?))
} }
} }
@ -142,8 +145,8 @@ impl From<&UserId> for Value {
} }
impl TryGetable for UserId { impl TryGetable for UserId {
fn try_get(res: &QueryResult, pre: &str, col: &str) -> Result<Self, TryGetError> { fn try_get_by<I: sea_orm::ColIdx>(res: &QueryResult, index: I) -> Result<Self, TryGetError> {
Ok(UserId::new(&String::try_get(res, pre, col)?)) Ok(UserId::new(&String::try_get_by(res, index)?))
} }
} }
@ -261,8 +264,8 @@ impl JpegPhoto {
} }
impl TryGetable for JpegPhoto { impl TryGetable for JpegPhoto {
fn try_get(res: &QueryResult, pre: &str, col: &str) -> Result<Self, TryGetError> { fn try_get_by<I: sea_orm::ColIdx>(res: &QueryResult, index: I) -> Result<Self, TryGetError> {
<Self as std::convert::TryFrom<Vec<_>>>::try_from(Vec::<u8>::try_get(res, pre, col)?) <Self as std::convert::TryFrom<Vec<_>>>::try_from(Vec::<u8>::try_get_by(res, index)?)
.map_err(|e| { .map_err(|e| {
TryGetError::DbErr(DbErr::TryIntoErr { TryGetError::DbErr(DbErr::TryIntoErr {
from: "[u8]", from: "[u8]",
@ -345,8 +348,8 @@ impl From<GroupId> for Value {
} }
impl TryGetable for GroupId { impl TryGetable for GroupId {
fn try_get(res: &QueryResult, pre: &str, col: &str) -> Result<Self, TryGetError> { fn try_get_by<I: sea_orm::ColIdx>(res: &QueryResult, index: I) -> Result<Self, TryGetError> {
Ok(GroupId(i32::try_get(res, pre, col)?)) Ok(GroupId(i32::try_get_by(res, index)?))
} }
} }
@ -364,7 +367,7 @@ impl ValueType for GroupId {
} }
fn column_type() -> ColumnType { fn column_type() -> ColumnType {
ColumnType::Integer(None) ColumnType::Integer
} }
} }

View File

@ -1,5 +1,7 @@
use sea_orm::ConnectionTrait; use sea_orm::{
use sea_query::{ColumnDef, ForeignKey, ForeignKeyAction, Iden, Table}; sea_query::{self, ColumnDef, ForeignKey, ForeignKeyAction, Iden, Table},
ConnectionTrait,
};
pub use crate::domain::{sql_migrations::Users, sql_tables::DbConnection}; pub use crate::domain::{sql_migrations::Users, sql_tables::DbConnection};

View File

@ -7,10 +7,10 @@ use crate::domain::{
}; };
use async_trait::async_trait; use async_trait::async_trait;
use sea_orm::{ use sea_orm::{
sea_query::Cond, ActiveModelTrait, ColumnTrait, EntityTrait, FromQueryResult, IntoActiveModel, sea_query::{Cond, Expr},
QueryFilter, QuerySelect, ActiveModelTrait, ColumnTrait, EntityTrait, FromQueryResult, IntoActiveModel, QueryFilter,
QuerySelect,
}; };
use sea_query::Expr;
use std::collections::HashSet; use std::collections::HashSet;
use tracing::{debug, instrument}; use tracing::{debug, instrument};