diff --git a/Cargo.toml b/Cargo.toml index e2f67e32..c93f8fce 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tardis" -version = "0.1.0-alpha15" +version = "0.1.0-alpha16" authors = ["gudaoxuri "] description = "Elegant, clean Rust development framework" keywords = ["http", "database", "web", "redis", "mq"] @@ -32,7 +32,7 @@ crypto = ["rust-crypto", "rsa"] crypto_with_sm = ["libsm", "num-bigint"] rt_tokio = ["tokio"] future = ["rt_tokio", "futures", "async-stream", "futures-util", "async-trait"] -reldb = ["future", "sqlparser", "sea-orm", "sea-query"] +reldb = ["future", "sqlparser", "sea-orm"] web-server = ["trace", "future", "poem", "poem-openapi", "poem-openapi-derive"] web-client = ["rt_tokio", "reqwest"] cache = ["futures-util", "redis"] @@ -43,77 +43,76 @@ test = ["testcontainers"] [dependencies] # Basic -serde = { version = "^1.0", features = ["derive"] } -serde_json = { version = "^1.0" } -derive_more = { version = "^0.99" } -nanoid = { version = "^0.4" } -base64 = { version = "^0.13" } -hex = { version = "^0.4" } -lazy_static = { version = "^1.4" } -log = { version = "^0.4" } -rand = { version = "^0.8" } -rand_core = { version = "^0.6" } -chrono = { version = "^0.4" } -env_logger = { version = "^0.9" } -config = { version = "^0.13" } -regex = { version = "^1.5" } -url = { version = "^2.2" } -openssl = { version = "^0.10", features = ["vendored"] } +serde = { version = "1", features = ["derive"] } +serde_json = { version = "1" } +derive_more = { version = "0.99" } +nanoid = { version = "0.4" } +base64 = { version = "0.13" } +hex = { version = "0.4" } +lazy_static = { version = "1.4" } +log = { version = "0.4" } +rand = { version = "0.8" } +rand_core = { version = "0.6" } +chrono = { version = "0.4" } +env_logger = { version = "0.9" } +config = { version = "0.13" } +regex = { version = "1.5" } +url = { version = "2.2" } +openssl = { version = "0.10", features = ["vendored"] } # Tokio -tokio = { version = "^1.18", features = ["macros", "rt-multi-thread", "signal", "time"], optional = true } +tokio = { version = "1.18", features = ["macros", "rt-multi-thread", "signal", "time"], optional = true } # Crypto -rust-crypto = { version = "^0.2", optional = true } -rsa = { version = "^0.5", optional = true } -libsm = { version = "^0.5", optional = true } -num-bigint = { version = "^0.4.3", optional = true } +rust-crypto = { version = "0.2", optional = true } +rsa = { version = "0.6", features = ["pem"], optional = true } +libsm = { version = "0.5", optional = true } +num-bigint = { version = "0.4.3", optional = true } # Future -futures = { version = "^0.3", optional = true } -async-stream = { version = "^0.3", optional = true } -futures-util = { version = "^0.3", optional = true } -async-trait = { version = "^0.1", optional = true } +futures = { version = "0.3", optional = true } +async-stream = { version = "0.3", optional = true } +futures-util = { version = "0.3", optional = true } +async-trait = { version = "0.1", optional = true } # Tracing -tracing = { version = "^0.1", optional = true } -tracing-subscriber = { version = "^0.3", features = ["env-filter"], optional = true } +tracing = { version = "0.1", optional = true } +tracing-subscriber = { version = "0.3", features = ["env-filter"], optional = true } # RelDB -sea-orm = { version = "^0.8", features = ["sqlx-all", "macros", "runtime-tokio-native-tls", "debug-print"], optional = true } -sea-query = { version = "^0.24", optional = true } -sqlparser = { version = "^0.17", optional = true } +sea-orm = { version = "0.9", features = ["sqlx-all", "macros", "runtime-tokio-native-tls", "debug-print"], optional = true } +sqlparser = { version = "0.17", optional = true } # Web Server -poem-openapi = { version = "^2", features = ["rapidoc", "chrono"], optional = true } -poem-openapi-derive = { version = "^2", optional = true } -poem = { version = "^1.3", features = ["csrf", "opentelemetry", "rustls", "prometheus", "websocket"], optional = true } +poem-openapi = { version = "2", features = ["rapidoc", "chrono"], optional = true } +poem-openapi-derive = { version = "2", optional = true } +poem = { version = "1.3", features = ["csrf", "opentelemetry", "rustls", "prometheus", "websocket"], optional = true } # Web Client -reqwest = { version = "^0.11", features = ["json"], optional = true } +reqwest = { version = "0.11", features = ["json"], optional = true } # Redis -redis = { version = "^0.21", features = ["tokio-comp", "tokio-native-tls-comp"], optional = true } +redis = { version = "0.21", features = ["tokio-comp", "tokio-native-tls-comp"], optional = true } # Rabbit -lapin = { version = "^2.0", optional = true } -amq-protocol-types = { version = "^7.0", optional = true } -async-global-executor = { version = "^2.0", optional = true } +lapin = { version = "2.0", optional = true } +amq-protocol-types = { version = "7.0", optional = true } +async-global-executor = { version = "2.0", optional = true } #Mail lettre = { version = "0.10.0-rc.6", features = ["smtp-transport", "tokio1", "tokio1-native-tls", "builder"], optional = true } #Object Storage -rust-s3 = { version = "^0.31", optional = true } -anyhow = { version = "^1.0", optional = true } +rust-s3 = { version = "0.31", optional = true } +anyhow = { version = "1.0", optional = true } # Test -testcontainers = { version = "^0.14", optional = true } +testcontainers = { version = "0.14", optional = true } [dev-dependencies] # Common -tokio = { version = "^1.18", features = ["time", "rt", "macros"] } -criterion = { version = "^0.3" } +tokio = { version = "1.18", features = ["time", "rt", "macros"] } +criterion = { version = "0.3" } [[test]] name = "test_basic_config" diff --git a/benches/crypto_benchmark.rs b/benches/crypto_benchmark.rs index 4c1a5d70..3362fe9d 100644 --- a/benches/crypto_benchmark.rs +++ b/benches/crypto_benchmark.rs @@ -42,7 +42,7 @@ Rust 拥有出色的文档、友好的编译器和清晰的错误提示信息, let private_key = TardisFuns::crypto.rsa.new_private_key(2048).unwrap(); let public_key = TardisFuns::crypto.rsa.new_public_key(&private_key).unwrap(); let signed_data = private_key.sign("测试").unwrap(); - let encrypted_data = private_key.encrypt("测试").unwrap(); + let encrypted_data = public_key.encrypt("测试").unwrap(); c.bench_function("CRYPTO: rsa_sign", |b| { b.iter(|| { private_key.sign("测试").unwrap(); diff --git a/examples/multi-apps/doc/Cargo.toml b/examples/multi-apps/doc/Cargo.toml index 65b796cf..d5b266f8 100644 --- a/examples/multi-apps/doc/Cargo.toml +++ b/examples/multi-apps/doc/Cargo.toml @@ -8,5 +8,5 @@ edition = "2021" serde = { version = "^1", features = ["derive"] } tardis = { path = "../../..", features = ["reldb", "web-server"] } -sea-orm = { version = "^0.8", features = ["macros"] } +sea-orm = { version = "^0.9", features = ["macros"] } poem-openapi = { version = "^2" } \ No newline at end of file diff --git a/examples/multi-apps/tag/Cargo.toml b/examples/multi-apps/tag/Cargo.toml index 05ca9ecf..eb9149e5 100644 --- a/examples/multi-apps/tag/Cargo.toml +++ b/examples/multi-apps/tag/Cargo.toml @@ -8,5 +8,5 @@ edition = "2021" serde = { version = "^1", features = ["derive"] } tardis = { path = "../../..", features = ["reldb", "web-server"] } -sea-orm = { version = "^0.8", features = ["macros"] } +sea-orm = { version = "^0.9", features = ["macros"] } poem-openapi = { version = "^2" } diff --git a/examples/multi-apps/tag/src/serv/tag_serv.rs b/examples/multi-apps/tag/src/serv/tag_serv.rs index f271b15d..76a83884 100644 --- a/examples/multi-apps/tag/src/serv/tag_serv.rs +++ b/examples/multi-apps/tag/src/serv/tag_serv.rs @@ -1,8 +1,8 @@ use tardis::basic::dto::TardisContext; use tardis::basic::error::TardisError; use tardis::basic::result::TardisResult; +use tardis::db::sea_orm::sea_query::{Expr, Query}; use tardis::db::sea_orm::*; -use tardis::db::sea_query::{Expr, Query}; use tardis::TardisFunsInst; use crate::domain::tag; diff --git a/examples/perf-test/Cargo.toml b/examples/perf-test/Cargo.toml index bcb7cce7..bbcb1d33 100644 --- a/examples/perf-test/Cargo.toml +++ b/examples/perf-test/Cargo.toml @@ -10,4 +10,4 @@ tardis = { path = "../..", features = ["web-server", "reldb"] } # Web server dependencies poem-openapi = { version = "^2" } # Reldb dependencies -sea-orm = { version = "^0.8", features = ["macros"] } +sea-orm = { version = "^0.9", features = ["macros"] } diff --git a/examples/perf-test/src/processor.rs b/examples/perf-test/src/processor.rs index 3347082c..3d0e6eed 100644 --- a/examples/perf-test/src/processor.rs +++ b/examples/perf-test/src/processor.rs @@ -1,6 +1,6 @@ use tardis::basic::dto::TardisContext; +use tardis::db::sea_orm::sea_query::Query as DbQuery; use tardis::db::sea_orm::*; -use tardis::db::sea_query::Query as DbQuery; use tardis::serde::{self, Deserialize, Serialize}; use tardis::web::poem_openapi::param::Query; use tardis::web::poem_openapi::{param::Path, payload::Json, Object, OpenApi}; diff --git a/examples/reldb/Cargo.toml b/examples/reldb/Cargo.toml index e799de67..494ac797 100644 --- a/examples/reldb/Cargo.toml +++ b/examples/reldb/Cargo.toml @@ -6,4 +6,4 @@ edition = "2021" [dependencies] tardis = { path = "../..", features = ["reldb", "test"] } -sea-orm = { version = "^0.8", features = ["macros"] } +sea-orm = { version = "^0.9", features = ["macros"] } diff --git a/examples/todos/Cargo.toml b/examples/todos/Cargo.toml index 4d75f524..152581c3 100644 --- a/examples/todos/Cargo.toml +++ b/examples/todos/Cargo.toml @@ -11,5 +11,5 @@ tardis = { path = "../..", features = ["web-server", "reldb", "test"] } # Web server dependencies poem-openapi = { version = "^2" } # Reldb dependencies -sea-orm = { version = "^0.8", features = ["macros"] } +sea-orm = { version = "^0.9", features = ["macros"] } diff --git a/examples/todos/src/processor.rs b/examples/todos/src/processor.rs index c93e6556..aec606cc 100644 --- a/examples/todos/src/processor.rs +++ b/examples/todos/src/processor.rs @@ -2,8 +2,8 @@ use serde::{Deserialize, Serialize}; use tardis::basic::error::TardisError; use tardis::basic::field::TrimString; +use tardis::db::sea_orm::sea_query::Query as DbQuery; use tardis::db::sea_orm::*; -use tardis::db::sea_query::Query as DbQuery; use tardis::web::context_extractor::TardisContextExtractor; use tardis::web::poem_openapi::param::Query; use tardis::web::poem_openapi::{param::Path, payload::Json, Object, OpenApi}; diff --git a/src/basic/crypto.rs b/src/basic/crypto.rs index 63d63d4d..bb150b1a 100644 --- a/src/basic/crypto.rs +++ b/src/basic/crypto.rs @@ -13,8 +13,8 @@ use libsm::{ #[cfg(feature = "crypto_with_sm")] use num_bigint::BigUint; use rand_core::RngCore; -use rsa::pkcs8::{FromPrivateKey, FromPublicKey, ToPrivateKey, ToPublicKey}; -use rsa::{pkcs8, PublicKey}; +use rsa::pkcs8::{DecodePrivateKey, DecodePublicKey, EncodePrivateKey, EncodePublicKey, LineEnding}; +use rsa::PublicKey; use crate::basic::error::TardisError; use crate::basic::result::TardisResult; @@ -40,29 +40,41 @@ pub struct TardisCrypto { #[cfg(feature = "crypto_with_sm")] pub sm2: TardisCryptoSm2, } + pub struct TardisCryptoHex; + pub struct TardisCryptoBase64; + pub struct TardisCryptoAes; + pub struct TardisCryptoRsa; + pub struct TardisCryptoRsaPrivateKey { pri_key: rsa::RsaPrivateKey, } + pub struct TardisCryptoRsaPublicKey { pub_key: rsa::RsaPublicKey, } + #[cfg(feature = "crypto_with_sm")] pub struct TardisCryptoSm4; + #[cfg(feature = "crypto_with_sm")] pub struct TardisCryptoSm2; + #[cfg(feature = "crypto_with_sm")] pub struct TardisCryptoSm2PrivateKey { pri_key: BigUint, } + #[cfg(feature = "crypto_with_sm")] pub struct TardisCryptoSm2PublicKey { pub_key: Point, } + pub struct TardisCryptoDigest; + pub struct TardisCryptoKey; impl TardisCryptoHex { @@ -229,12 +241,12 @@ impl TardisCryptoRsaPrivateKey { pub fn from(private_key_pem: &str) -> TardisResult { Ok(TardisCryptoRsaPrivateKey { - pri_key: rsa::RsaPrivateKey::from_pkcs8_pem(private_key_pem)?, + pri_key: rsa::RsaPrivateKey::from_pkcs8_pem(private_key_pem).map_err(|e| TardisError::FormatError(format!("[Tardis.Crypto] RSA crypto error, {}", e)))?, }) } pub fn serialize(&self) -> TardisResult { - Ok(self.pri_key.to_pkcs8_pem()?.to_string()) + Ok(self.pri_key.to_pkcs8_pem(LineEnding::LF).map_err(|e| TardisError::FormatError(format!("[Tardis.Crypto] RSA crypto error, {}", e)))?.to_string()) } pub fn decrypt(&self, encrypted_data: &str) -> TardisResult { @@ -256,19 +268,19 @@ impl TardisCryptoRsaPublicKey { } pub fn from_private_key_str(private_key_pem: &str) -> TardisResult { - let private_key = rsa::RsaPrivateKey::from_pkcs8_pem(private_key_pem)?; + let private_key = rsa::RsaPrivateKey::from_pkcs8_pem(private_key_pem).map_err(|e| TardisError::FormatError(format!("[Tardis.Crypto] RSA crypto error, {}", e)))?; let public_key = rsa::RsaPublicKey::from(private_key); Ok(TardisCryptoRsaPublicKey { pub_key: public_key }) } pub fn from_public_key_str(public_key_pem: &str) -> TardisResult { Ok(TardisCryptoRsaPublicKey { - pub_key: rsa::RsaPublicKey::from_public_key_pem(public_key_pem)?, + pub_key: rsa::RsaPublicKey::from_public_key_pem(public_key_pem).map_err(|e| TardisError::FormatError(format!("[Tardis.Crypto] RSA crypto error, {}", e)))?, }) } pub fn serialize(&self) -> TardisResult { - Ok(self.pub_key.to_public_key_pem()?) + self.pub_key.to_public_key_pem(LineEnding::LF).map_err(|e| TardisError::FormatError(format!("[Tardis.Crypto] RSA crypto error, {}", e))) } pub fn encrypt(&self, data: &str) -> TardisResult { @@ -554,9 +566,3 @@ impl From for TardisError { TardisError::FormatError(format!("[Tardis.Crypto] RSA crypto error, {}", error)) } } - -impl From for TardisError { - fn from(error: pkcs8::Error) -> Self { - TardisError::FormatError(format!("[Tardis.Crypto] RSA crypto error, {}", error)) - } -} diff --git a/src/db.rs b/src/db.rs index cc75becb..a292173a 100644 --- a/src/db.rs +++ b/src/db.rs @@ -1,5 +1,4 @@ pub use sea_orm; -pub use sea_query; pub mod domain; pub mod reldb_client; diff --git a/src/db/domain/tardis_db_config.rs b/src/db/domain/tardis_db_config.rs index 723d235f..63c177cf 100644 --- a/src/db/domain/tardis_db_config.rs +++ b/src/db/domain/tardis_db_config.rs @@ -5,9 +5,9 @@ use crate::basic::dto::TardisContext; use crate::db::domain::tardis_db_config; use crate::db::reldb_client::{TardisActiveModel, TardisRelDBlConnection}; use crate::db::sea_orm::entity::prelude::*; +use crate::db::sea_orm::sea_query::{ColumnDef, Table, TableCreateStatement}; use crate::db::sea_orm::ActiveValue::Set; use crate::db::sea_orm::{ActiveModelBehavior, DbBackend}; -use crate::db::sea_query::{ColumnDef, Table, TableCreateStatement}; use crate::TardisResult; #[derive(Clone, Debug, PartialEq, DeriveEntityModel)] diff --git a/src/db/domain/tardis_db_del_record.rs b/src/db/domain/tardis_db_del_record.rs index 629a8b79..232da293 100644 --- a/src/db/domain/tardis_db_del_record.rs +++ b/src/db/domain/tardis_db_del_record.rs @@ -1,9 +1,9 @@ use crate::basic::dto::TardisContext; use crate::db::reldb_client::TardisActiveModel; use crate::db::sea_orm::entity::prelude::*; +use crate::db::sea_orm::sea_query::{ColumnDef, Table, TableCreateStatement}; use crate::db::sea_orm::ActiveValue::Set; use crate::db::sea_orm::{ActiveModelBehavior, DbBackend}; -use crate::db::sea_query::{ColumnDef, Table, TableCreateStatement}; use crate::TardisFuns; #[derive(Clone, Debug, PartialEq, DeriveEntityModel)] diff --git a/src/db/reldb_client.rs b/src/db/reldb_client.rs index f114fe87..bd6a1db4 100644 --- a/src/db/reldb_client.rs +++ b/src/db/reldb_client.rs @@ -5,10 +5,10 @@ use std::time::{SystemTime, UNIX_EPOCH}; use async_trait::async_trait; use log::{error, trace}; use sea_orm::sea_query::TableCreateStatement; +use sea_orm::sea_query::{IndexCreateStatement, SelectStatement, UpdateStatement}; use sea_orm::ActiveValue::Set; use sea_orm::*; use sea_orm::{ConnectOptions, ConnectionTrait, Database, DatabaseConnection, DbBackend, DbErr, EntityTrait, ExecResult, QueryTrait, Schema, Select, Statement}; -use sea_query::{IndexCreateStatement, SelectStatement, UpdateStatement}; use sqlparser::ast; use sqlparser::ast::{SetExpr, TableFactor}; use sqlparser::dialect::MySqlDialect; @@ -44,7 +44,7 @@ use crate::{FrameworkConfig, TardisFuns}; /// use sea_orm::{DeriveRelation, EnumIter}; /// mod tardis_db_config{ /// use tardis::db::sea_orm::*; -/// use tardis::db::sea_query::*; +/// use tardis::db::sea_orm::sea_query::*; /// use tardis::basic::dto::TardisContext; /// use tardis::db::domain::tardis_db_config; /// use tardis::db::reldb_client::TardisActiveModel; @@ -105,7 +105,7 @@ use crate::{FrameworkConfig, TardisFuns}; /// use tardis::basic::dto::TardisContext; /// use tardis::db::domain::tardis_db_config; /// use tardis::db::reldb_client::IdResp; -/// use tardis::db::sea_query::*; +/// use tardis::db::sea_orm::sea_query::*; /// use tardis::db::sea_orm::*; /// use tardis::TardisFuns; /// let cxt = TardisContext{ @@ -577,7 +577,7 @@ impl<'a> TardisRelDBlConnection<'a> { /// /// # Examples /// ```ignore - /// use tardis::db::sea_query::*; + /// use tardis::db::sea_orm::sea_query::*; /// use tardis::db::domain::tardis_db_config; /// use tardis::db::reldb_client::TardisActiveModel; /// use tardis::TardisFuns; @@ -608,7 +608,7 @@ impl<'a> TardisRelDBlConnection<'a> { /// /// # Examples /// ```ignore - /// use tardis::db::sea_query::*; + /// use tardis::db::sea_orm::sea_query::*; /// use tardis::db::domain::tardis_db_config; /// use tardis::db::reldb_client::TardisActiveModel; /// use tardis::TardisFuns; @@ -640,7 +640,7 @@ impl<'a> TardisRelDBlConnection<'a> { /// /// # Examples /// ```ignore - /// use tardis::db::sea_query::*; + /// use tardis::db::sea_orm::sea_query::*; /// use tardis::db::domain::tardis_db_config; /// use tardis::db::reldb_client::TardisActiveModel; /// use tardis::TardisFuns; @@ -671,7 +671,7 @@ impl<'a> TardisRelDBlConnection<'a> { /// /// # Examples /// ```ignore - /// use tardis::db::sea_query::*; + /// use tardis::db::sea_orm::sea_query::*; /// use tardis::db::domain::tardis_db_config; /// use tardis::db::reldb_client::TardisActiveModel; /// use tardis::TardisFuns; @@ -718,7 +718,7 @@ impl<'a> TardisRelDBlConnection<'a> { /// # Examples /// ```ignore /// use tardis::db::sea_orm::*; - /// use tardis::db::sea_query::*; + /// use tardis::db::sea_orm::sea_query::*; /// use tardis::db::domain::tardis_db_config; /// use tardis::db::reldb_client::TardisActiveModel; /// use tardis::TardisFuns; @@ -750,7 +750,7 @@ impl<'a> TardisRelDBlConnection<'a> { /// # Examples /// ```ignore /// use tardis::db::sea_orm::*; - /// use tardis::db::sea_query::*; + /// use tardis::db::sea_orm::sea_query::*; /// use tardis::db::domain::tardis_db_config; /// use tardis::db::reldb_client::TardisActiveModel; /// use tardis::TardisFuns; @@ -784,7 +784,7 @@ impl<'a> TardisRelDBlConnection<'a> { /// # Examples /// ```ignore /// use tardis::db::sea_orm::*; - /// use tardis::db::sea_query::*; + /// use tardis::db::sea_orm::sea_query::*; /// use tardis::db::domain::tardis_db_config; /// use tardis::db::reldb_client::TardisActiveModel; /// use tardis::TardisFuns; @@ -816,7 +816,7 @@ impl<'a> TardisRelDBlConnection<'a> { /// # Examples /// ```ignore /// use tardis::db::sea_orm::*; - /// use tardis::db::sea_query::*; + /// use tardis::db::sea_orm::sea_query::*; /// use tardis::db::domain::tardis_db_config; /// use tardis::db::reldb_client::TardisActiveModel; /// use tardis::TardisFuns; @@ -846,7 +846,7 @@ impl<'a> TardisRelDBlConnection<'a> { /// # Examples /// ```ignore /// use tardis::db::sea_orm::*; - /// use tardis::db::sea_query::*; + /// use tardis::db::sea_orm::sea_query::*; /// use tardis::db::domain::tardis_db_config; /// use tardis::db::reldb_client::TardisActiveModel; /// use tardis::TardisFuns; @@ -875,7 +875,7 @@ impl<'a> TardisRelDBlConnection<'a> { /// # Examples /// ```ignore /// use tardis::db::sea_orm::*; - /// use tardis::db::sea_query::*; + /// use tardis::db::sea_orm::sea_query::*; /// use tardis::db::domain::tardis_db_config; /// use tardis::db::reldb_client::TardisActiveModel; /// use tardis::TardisFuns; @@ -1046,7 +1046,7 @@ pub trait TardisActiveModel: ActiveModelBehavior { /// # Examples /// ```ignore /// use tardis::db::sea_orm::*; - /// use tardis::db::sea_query::*; + /// use tardis::db::sea_orm::sea_query::*; /// use tardis::basic::dto::TardisContext; /// fn create_table_and_index_statement(db: DbBackend) -> (TableCreateStatement, Vec) { /// (Self::create_table_statement(db), Self::create_index_statement()) @@ -1066,7 +1066,7 @@ pub trait TardisActiveModel: ActiveModelBehavior { /// ```ignore /// use tardis::db::domain::tardis_db_config; /// use tardis::db::sea_orm::*; - /// use tardis::db::sea_query::*; + /// use tardis::db::sea_orm::sea_query::*; /// fn create_table_statement(db_type: DbBackend) -> TableCreateStatement { /// match db_type { /// DbBackend::MySql => Table::create() @@ -1113,7 +1113,7 @@ pub trait TardisActiveModel: ActiveModelBehavior { /// ```ignore /// use tardis::db::domain::tardis_db_config; /// use tardis::db::sea_orm::*; - /// use tardis::db::sea_query::*; + /// use tardis::db::sea_orm::sea_query::*; /// fn create_index_statement() -> Vec { /// vec![ /// Index::create() diff --git a/src/lib.rs b/src/lib.rs index 8cc0a03c..29a73356 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -616,7 +616,7 @@ impl TardisFuns { /// use tardis::basic::error::TardisError; /// use tardis::TardisFuns; /// use tardis::db::sea_orm::*; - /// use tardis::db::sea_query::Query; + /// use tardis::db::sea_orm::sea_query::Query; /// // Initialize table structure /// TardisFuns::reldb().conn().create_table_from_entity(todos::Entity).await?; /// // Create record diff --git a/tests/test_reldb_client.rs b/tests/test_reldb_client.rs index 5677b712..12a76837 100644 --- a/tests/test_reldb_client.rs +++ b/tests/test_reldb_client.rs @@ -10,8 +10,8 @@ use tardis::basic::result::TardisResult; use tardis::db::domain::{tardis_db_config, tardis_db_del_record}; use tardis::db::reldb_client::TardisRelDBClient; use tardis::db::reldb_client::TardisSeaORMExtend; +use tardis::db::sea_orm::sea_query::*; use tardis::db::sea_orm::*; -use tardis::db::sea_query::*; use tardis::log::info; use tardis::test::test_container::TardisTestContainer; use tardis::TardisFuns; @@ -248,22 +248,6 @@ async fn test_advanced_query(client: &TardisRelDBClient) -> TardisResult<()> { assert_eq!(apps.len(), 2); assert_eq!(apps[0]["tenant_name"], "tenant1"); - let apps = entities::app::Entity::find() - .select_only() - .column(entities::app::Column::Name) - .column_as(entities::tenant::Column::Name, "tenant_name") - .join( - JoinType::LeftJoin, - // construct `RelationDef` on the fly - entities::app::Entity::belongs_to(entities::tenant::Entity).from(entities::app::Column::TenantId).to(entities::tenant::Column::Id).into(), - ) - .filter(entities::tenant::Column::Name.contains("tenant")) - .into_json() - .all(conn) - .await?; - assert_eq!(apps.len(), 2); - assert_eq!(apps[0]["tenant_name"], "tenant1"); - Ok(()) } @@ -529,7 +513,6 @@ async fn test_data_dict(client: &TardisRelDBClient) -> TardisResult<()> { } pub mod entities { - pub mod tenant { use sea_orm::entity::prelude::*; use sea_orm::ActiveModelBehavior;