update sea-orm

This commit is contained in:
manuel 2022-12-31 16:48:44 +01:00
parent a600ff5c9c
commit 7b4e2628b2
8 changed files with 28 additions and 36 deletions

View File

@ -17,26 +17,26 @@ name = "actix_admin"
path = "src/lib.rs"
[dependencies]
actix-web = "^4.0.1"
actix-session = { version = "^0.7.1", features = [] }
actix-web = "^4.2.1"
actix-session = { version = "^0.7.2", features = [] }
actix-multipart = "^0.4.0"
actix-files = "^0.6.2"
futures-util = "0.3.21"
chrono = "0.4.20"
tera = "^1.16.0"
async-trait = "^0.1.53"
futures-util = "0.3.25"
chrono = "0.4.23"
tera = "^1.17.1"
async-trait = "^0.1.60"
lazy_static = "^1.4.0"
itertools = "^0.10.3"
serde = "^1.0.136"
serde_derive = "^1.0.136"
sea-orm = { version = "^0.9.1", features = [], default-features = false }
itertools = "^0.10.5"
serde = "^1.0.152"
serde_derive = "^1.0.152"
sea-orm = { version = "^0.10.6", features = [], default-features = false }
actix-admin-macros = { version = "0.2.0", path = "actix_admin_macros" }
derive_more = "0.99.17"
[dev-dependencies]
sea-orm = { version = "^0.9.1", features = [ "sqlx-sqlite", "runtime-actix-native-tls", "macros" ], default-features = true }
sea-orm = { version = "^0.10.6", features = [ "sqlx-sqlite", "runtime-actix-native-tls", "macros" ], default-features = true }
actix-rt = "2.7.0"
azure_auth = { path = "./examples/azure_auth/azure_auth" }
oauth2 = "4.1"
oauth2 = "4.3"
dotenv = "0.15"
actix-session = { version = "0.7.1", features = ["cookie-session"] }
actix-session = { version = "0.7.2", features = ["cookie-session"] }

View File

@ -68,7 +68,7 @@ pub fn derive_actix_admin_view_model(input: proc_macro::TokenStream) -> proc_mac
#[actix_admin::prelude::async_trait(?Send)]
impl ActixAdminViewModelTrait for Entity {
async fn list(db: &DatabaseConnection, page: usize, entities_per_page: usize, search: &String) -> Result<(usize, Vec<ActixAdminModel>), ActixAdminError> {
async fn list(db: &DatabaseConnection, page: u64, entities_per_page: u64, search: &String) -> Result<(u64, Vec<ActixAdminModel>), ActixAdminError> {
let entities = Entity::list_model(db, page, entities_per_page, search).await;
entities
}
@ -236,7 +236,7 @@ pub fn derive_actix_admin_model(input: proc_macro::TokenStream) -> proc_macro::T
#[actix_admin::prelude::async_trait]
impl ActixAdminModelTrait for Entity {
async fn list_model(db: &DatabaseConnection, page: usize, posts_per_page: usize, search: &String) -> Result<(usize, Vec<ActixAdminModel>), ActixAdminError> {
async fn list_model(db: &DatabaseConnection, page: u64, posts_per_page: u64, search: &String) -> Result<(u64, Vec<ActixAdminModel>), ActixAdminError> {
use sea_orm::{ query::* };
let paginator = Entity::find()
.filter(

View File

@ -38,7 +38,8 @@ pub fn get_select_list_from_enum(input: proc_macro::TokenStream) -> proc_macro::
async fn get_key_value(db: &DatabaseConnection) -> Result<Vec<(String, String)>, ActixAdminError> {
let mut fields = Vec::new();
for field in #ty::iter() {
fields.push((field.to_string(), field.to_string()));
let field_val = field.to_string().trim_start_matches("'").trim_end_matches("'").to_string();
fields.push((field_val.clone(), field_val));
}
Ok(fields)
}

View File

@ -272,14 +272,14 @@ pub fn get_fields_for_from_model(fields: &Vec<ModelField>) -> Vec<TokenStream> {
true => {
quote! {
#ident_name => match model.#ident {
Some(val) => val.to_string(),
Some(val) => val.to_string().trim_start_matches("'").trim_end_matches("'").to_string(),
None => "".to_owned()
}
}
}
false => {
quote! {
#ident_name => model.#ident.to_string()
#ident_name => model.#ident.to_string().trim_start_matches("'").trim_end_matches("'").to_string()
}
}
}

View File

@ -69,13 +69,4 @@ impl FromStr for Tea {
}
}
impl Display for Tea {
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
match &*self {
Tea::EverydayTea => write!(formatter, "{}", String::from("EverydayTea")),
Tea::BreakfastTea => write!(formatter, "{}", String::from("BreakfastTea")),
}
}
}
impl ActixAdminModelValidationTrait<ActiveModel> for Entity {}

View File

@ -15,10 +15,10 @@ use std::time::{SystemTime, UNIX_EPOCH};
pub trait ActixAdminModelTrait {
async fn list_model(
db: &DatabaseConnection,
page: usize,
posts_per_page: usize,
page: u64,
posts_per_page: u64,
search: &String,
) -> Result<(usize, Vec<ActixAdminModel>), ActixAdminError>;
) -> Result<(u64, Vec<ActixAdminModel>), ActixAdminError>;
fn get_fields() -> &'static [ActixAdminViewModelField];
fn validate_model(model: &mut ActixAdminModel);
}

View File

@ -11,12 +11,12 @@ use crate::TERA;
use actix_session::{Session};
use super::{ add_auth_context, user_can_access_page, render_unauthorized};
const DEFAULT_ENTITIES_PER_PAGE: usize = 10;
const DEFAULT_ENTITIES_PER_PAGE: u64 = 10;
#[derive(Debug, Deserialize)]
pub struct Params {
page: Option<usize>,
entities_per_page: Option<usize>,
page: Option<u64>,
entities_per_page: Option<u64>,
render_partial: Option<bool>,
search: Option<String>
}

View File

@ -11,10 +11,10 @@ use crate::ActixAdminError;
pub trait ActixAdminViewModelTrait {
async fn list(
db: &DatabaseConnection,
page: usize,
entities_per_page: usize,
page: u64,
entities_per_page: u64,
search: &String
) -> Result<(usize, Vec<ActixAdminModel>), ActixAdminError>;
) -> Result<(u64, Vec<ActixAdminModel>), ActixAdminError>;
// TODO: Replace return value with proper Result Type containing Ok or Err
async fn create_entity(db: &DatabaseConnection, model: ActixAdminModel) -> Result<ActixAdminModel, ActixAdminError>;