update sea-orm
This commit is contained in:
parent
a600ff5c9c
commit
7b4e2628b2
26
Cargo.toml
26
Cargo.toml
@ -17,26 +17,26 @@ name = "actix_admin"
|
|||||||
path = "src/lib.rs"
|
path = "src/lib.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-web = "^4.0.1"
|
actix-web = "^4.2.1"
|
||||||
actix-session = { version = "^0.7.1", features = [] }
|
actix-session = { version = "^0.7.2", features = [] }
|
||||||
actix-multipart = "^0.4.0"
|
actix-multipart = "^0.4.0"
|
||||||
actix-files = "^0.6.2"
|
actix-files = "^0.6.2"
|
||||||
futures-util = "0.3.21"
|
futures-util = "0.3.25"
|
||||||
chrono = "0.4.20"
|
chrono = "0.4.23"
|
||||||
tera = "^1.16.0"
|
tera = "^1.17.1"
|
||||||
async-trait = "^0.1.53"
|
async-trait = "^0.1.60"
|
||||||
lazy_static = "^1.4.0"
|
lazy_static = "^1.4.0"
|
||||||
itertools = "^0.10.3"
|
itertools = "^0.10.5"
|
||||||
serde = "^1.0.136"
|
serde = "^1.0.152"
|
||||||
serde_derive = "^1.0.136"
|
serde_derive = "^1.0.152"
|
||||||
sea-orm = { version = "^0.9.1", features = [], default-features = false }
|
sea-orm = { version = "^0.10.6", features = [], default-features = false }
|
||||||
actix-admin-macros = { version = "0.2.0", path = "actix_admin_macros" }
|
actix-admin-macros = { version = "0.2.0", path = "actix_admin_macros" }
|
||||||
derive_more = "0.99.17"
|
derive_more = "0.99.17"
|
||||||
|
|
||||||
[dev-dependencies]
|
[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"
|
actix-rt = "2.7.0"
|
||||||
azure_auth = { path = "./examples/azure_auth/azure_auth" }
|
azure_auth = { path = "./examples/azure_auth/azure_auth" }
|
||||||
oauth2 = "4.1"
|
oauth2 = "4.3"
|
||||||
dotenv = "0.15"
|
dotenv = "0.15"
|
||||||
actix-session = { version = "0.7.1", features = ["cookie-session"] }
|
actix-session = { version = "0.7.2", features = ["cookie-session"] }
|
@ -68,7 +68,7 @@ pub fn derive_actix_admin_view_model(input: proc_macro::TokenStream) -> proc_mac
|
|||||||
|
|
||||||
#[actix_admin::prelude::async_trait(?Send)]
|
#[actix_admin::prelude::async_trait(?Send)]
|
||||||
impl ActixAdminViewModelTrait for Entity {
|
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;
|
let entities = Entity::list_model(db, page, entities_per_page, search).await;
|
||||||
entities
|
entities
|
||||||
}
|
}
|
||||||
@ -236,7 +236,7 @@ pub fn derive_actix_admin_model(input: proc_macro::TokenStream) -> proc_macro::T
|
|||||||
|
|
||||||
#[actix_admin::prelude::async_trait]
|
#[actix_admin::prelude::async_trait]
|
||||||
impl ActixAdminModelTrait for Entity {
|
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::* };
|
use sea_orm::{ query::* };
|
||||||
let paginator = Entity::find()
|
let paginator = Entity::find()
|
||||||
.filter(
|
.filter(
|
||||||
|
@ -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> {
|
async fn get_key_value(db: &DatabaseConnection) -> Result<Vec<(String, String)>, ActixAdminError> {
|
||||||
let mut fields = Vec::new();
|
let mut fields = Vec::new();
|
||||||
for field in #ty::iter() {
|
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)
|
Ok(fields)
|
||||||
}
|
}
|
||||||
|
@ -272,14 +272,14 @@ pub fn get_fields_for_from_model(fields: &Vec<ModelField>) -> Vec<TokenStream> {
|
|||||||
true => {
|
true => {
|
||||||
quote! {
|
quote! {
|
||||||
#ident_name => match model.#ident {
|
#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()
|
None => "".to_owned()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
false => {
|
false => {
|
||||||
quote! {
|
quote! {
|
||||||
#ident_name => model.#ident.to_string()
|
#ident_name => model.#ident.to_string().trim_start_matches("'").trim_end_matches("'").to_string()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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 {}
|
impl ActixAdminModelValidationTrait<ActiveModel> for Entity {}
|
@ -15,10 +15,10 @@ use std::time::{SystemTime, UNIX_EPOCH};
|
|||||||
pub trait ActixAdminModelTrait {
|
pub trait ActixAdminModelTrait {
|
||||||
async fn list_model(
|
async fn list_model(
|
||||||
db: &DatabaseConnection,
|
db: &DatabaseConnection,
|
||||||
page: usize,
|
page: u64,
|
||||||
posts_per_page: usize,
|
posts_per_page: u64,
|
||||||
search: &String,
|
search: &String,
|
||||||
) -> Result<(usize, Vec<ActixAdminModel>), ActixAdminError>;
|
) -> Result<(u64, Vec<ActixAdminModel>), ActixAdminError>;
|
||||||
fn get_fields() -> &'static [ActixAdminViewModelField];
|
fn get_fields() -> &'static [ActixAdminViewModelField];
|
||||||
fn validate_model(model: &mut ActixAdminModel);
|
fn validate_model(model: &mut ActixAdminModel);
|
||||||
}
|
}
|
||||||
|
@ -11,12 +11,12 @@ use crate::TERA;
|
|||||||
use actix_session::{Session};
|
use actix_session::{Session};
|
||||||
use super::{ add_auth_context, user_can_access_page, render_unauthorized};
|
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)]
|
#[derive(Debug, Deserialize)]
|
||||||
pub struct Params {
|
pub struct Params {
|
||||||
page: Option<usize>,
|
page: Option<u64>,
|
||||||
entities_per_page: Option<usize>,
|
entities_per_page: Option<u64>,
|
||||||
render_partial: Option<bool>,
|
render_partial: Option<bool>,
|
||||||
search: Option<String>
|
search: Option<String>
|
||||||
}
|
}
|
||||||
|
@ -11,10 +11,10 @@ use crate::ActixAdminError;
|
|||||||
pub trait ActixAdminViewModelTrait {
|
pub trait ActixAdminViewModelTrait {
|
||||||
async fn list(
|
async fn list(
|
||||||
db: &DatabaseConnection,
|
db: &DatabaseConnection,
|
||||||
page: usize,
|
page: u64,
|
||||||
entities_per_page: usize,
|
entities_per_page: u64,
|
||||||
search: &String
|
search: &String
|
||||||
) -> Result<(usize, Vec<ActixAdminModel>), ActixAdminError>;
|
) -> Result<(u64, Vec<ActixAdminModel>), ActixAdminError>;
|
||||||
|
|
||||||
// TODO: Replace return value with proper Result Type containing Ok or Err
|
// TODO: Replace return value with proper Result Type containing Ok or Err
|
||||||
async fn create_entity(db: &DatabaseConnection, model: ActixAdminModel) -> Result<ActixAdminModel, ActixAdminError>;
|
async fn create_entity(db: &DatabaseConnection, model: ActixAdminModel) -> Result<ActixAdminModel, ActixAdminError>;
|
||||||
|
Loading…
Reference in New Issue
Block a user