* chore: add clippy config file * refactor: fix clippy errors and wornings of runtime-async-std-native-tls,sqlx-all * refactor: fix clippy errors and wornings of sqlx-sqlite, sqlx-mysql, sqlx-postgres * chore: format * refactor: fix clippy * fix: import path * refactor: fix clippy errors and wornings of sqlx-sqlite, sqlx-mysql, sqlx-postgres * fix: revert some space and comma removal * fix: revert some space and comma removal * refactor: add feature flag * fix: import path * test: remove mismatch feature flag * test: remove mismatch feature flag * chore: add proper feature flag * chore: remove feature flag * refactor: remove clippy.toml file * fix: re-export driver * fix: re-export JoinType * fix: remove feature flag * chore: add #[allow(unused_imports)] for driver Co-authored-by: Shogo Nakano <61229807+shogo-nakano-desu@users.noreply.github.com>
This commit is contained in:
parent
3dc66aa17d
commit
f54683d365
@ -1,4 +1,3 @@
|
|||||||
pub use self::case_style::CaseStyleHelpers;
|
|
||||||
pub use self::type_props::HasTypeProperties;
|
pub use self::type_props::HasTypeProperties;
|
||||||
pub use self::variant_props::HasStrumVariantProperties;
|
pub use self::variant_props::HasStrumVariantProperties;
|
||||||
|
|
||||||
|
@ -117,6 +117,10 @@ impl MockDatabaseConnection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Get the [DatabaseBackend](crate::DatabaseBackend) being used by the [MockDatabase]
|
/// Get the [DatabaseBackend](crate::DatabaseBackend) being used by the [MockDatabase]
|
||||||
|
///
|
||||||
|
/// # Panics
|
||||||
|
///
|
||||||
|
/// Will panic if the lock cannot be acquired.
|
||||||
pub fn get_database_backend(&self) -> DbBackend {
|
pub fn get_database_backend(&self) -> DbBackend {
|
||||||
self.mocker
|
self.mocker
|
||||||
.lock()
|
.lock()
|
||||||
|
@ -345,6 +345,7 @@ pub mod tests_cfg;
|
|||||||
mod util;
|
mod util;
|
||||||
|
|
||||||
pub use database::*;
|
pub use database::*;
|
||||||
|
#[allow(unused_imports)]
|
||||||
pub use driver::*;
|
pub use driver::*;
|
||||||
pub use entity::*;
|
pub use entity::*;
|
||||||
pub use error::*;
|
pub use error::*;
|
||||||
|
@ -2,7 +2,6 @@ use crate::{
|
|||||||
ColumnTrait, EntityTrait, IdenStatic, Iterable, QueryTrait, Select, SelectTwo, SelectTwoMany,
|
ColumnTrait, EntityTrait, IdenStatic, Iterable, QueryTrait, Select, SelectTwo, SelectTwoMany,
|
||||||
};
|
};
|
||||||
use core::marker::PhantomData;
|
use core::marker::PhantomData;
|
||||||
pub use sea_query::JoinType;
|
|
||||||
use sea_query::{Alias, ColumnRef, Iden, Order, SeaRc, SelectExpr, SelectStatement, SimpleExpr};
|
use sea_query::{Alias, ColumnRef, Iden, Order, SeaRc, SelectExpr, SelectStatement, SimpleExpr};
|
||||||
|
|
||||||
macro_rules! select_def {
|
macro_rules! select_def {
|
||||||
|
@ -15,7 +15,6 @@ pub use combine::{SelectA, SelectB};
|
|||||||
pub use delete::*;
|
pub use delete::*;
|
||||||
pub use helper::*;
|
pub use helper::*;
|
||||||
pub use insert::*;
|
pub use insert::*;
|
||||||
pub use join::*;
|
|
||||||
#[cfg(feature = "with-json")]
|
#[cfg(feature = "with-json")]
|
||||||
pub use json::*;
|
pub use json::*;
|
||||||
pub use loader::*;
|
pub use loader::*;
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
use crate::{ColumnTrait, EntityTrait, Iterable, QueryFilter, QueryOrder, QuerySelect, QueryTrait};
|
use crate::{ColumnTrait, EntityTrait, Iterable, QueryFilter, QueryOrder, QuerySelect, QueryTrait};
|
||||||
use core::fmt::Debug;
|
use core::fmt::Debug;
|
||||||
use core::marker::PhantomData;
|
use core::marker::PhantomData;
|
||||||
pub use sea_query::JoinType;
|
|
||||||
use sea_query::{Expr, IntoColumnRef, SelectStatement, SimpleExpr};
|
use sea_query::{Expr, IntoColumnRef, SelectStatement, SimpleExpr};
|
||||||
|
|
||||||
/// Defines a structure to perform select operations
|
/// Defines a structure to perform select operations
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
pub mod common;
|
pub mod common;
|
||||||
|
|
||||||
use active_enum::Entity as ActiveEnum;
|
use active_enum::Entity as ActiveEnumEntity;
|
||||||
use active_enum_child::Entity as ActiveEnumChild;
|
|
||||||
pub use common::{features::*, setup::*, TestContext};
|
pub use common::{features::*, setup::*, TestContext};
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
|
#[cfg(feature = "sqlx-postgres")]
|
||||||
|
use sea_orm::QueryTrait;
|
||||||
use sea_orm::{
|
use sea_orm::{
|
||||||
entity::prelude::*,
|
entity::prelude::*,
|
||||||
entity::*,
|
entity::*,
|
||||||
sea_query::{BinOper, Expr},
|
sea_query::{BinOper, Expr},
|
||||||
ActiveEnum as ActiveEnumTrait, DatabaseConnection, QueryTrait,
|
ActiveEnum as ActiveEnumTrait, DatabaseConnection,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[sea_orm_macros::test]
|
#[sea_orm_macros::test]
|
||||||
@ -146,6 +147,7 @@ pub async fn insert_active_enum(db: &DatabaseConnection) -> Result<(), DbErr> {
|
|||||||
let select_with_tea_not_in = Entity::find()
|
let select_with_tea_not_in = Entity::find()
|
||||||
.filter(Column::Tea.is_not_null())
|
.filter(Column::Tea.is_not_null())
|
||||||
.filter(Column::Tea.is_not_in([Tea::BreakfastTea]));
|
.filter(Column::Tea.is_not_in([Tea::BreakfastTea]));
|
||||||
|
|
||||||
#[cfg(feature = "sqlx-postgres")]
|
#[cfg(feature = "sqlx-postgres")]
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
select_with_tea_not_in
|
select_with_tea_not_in
|
||||||
@ -162,6 +164,7 @@ pub async fn insert_active_enum(db: &DatabaseConnection) -> Result<(), DbErr> {
|
|||||||
]
|
]
|
||||||
.join(" ")
|
.join(" ")
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(model, select_with_tea_not_in.one(db).await?.unwrap());
|
assert_eq!(model, select_with_tea_not_in.one(db).await?.unwrap());
|
||||||
|
|
||||||
let res = model.delete(db).await?;
|
let res = model.delete(db).await?;
|
||||||
@ -338,7 +341,7 @@ pub async fn find_related_active_enum(db: &DatabaseConnection) -> Result<(), DbE
|
|||||||
}]
|
}]
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
ActiveEnum::find()
|
ActiveEnumEntity::find()
|
||||||
.find_with_related(ActiveEnumChild)
|
.find_with_related(ActiveEnumChild)
|
||||||
.all(db)
|
.all(db)
|
||||||
.await?,
|
.await?,
|
||||||
@ -359,7 +362,7 @@ pub async fn find_related_active_enum(db: &DatabaseConnection) -> Result<(), DbE
|
|||||||
)]
|
)]
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
ActiveEnum::find()
|
ActiveEnumEntity::find()
|
||||||
.find_also_related(ActiveEnumChild)
|
.find_also_related(ActiveEnumChild)
|
||||||
.all(db)
|
.all(db)
|
||||||
.await?,
|
.await?,
|
||||||
@ -464,7 +467,7 @@ pub async fn find_linked_active_enum(db: &DatabaseConnection) -> Result<(), DbEr
|
|||||||
}]
|
}]
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
ActiveEnum::find()
|
ActiveEnumEntity::find()
|
||||||
.find_also_linked(active_enum::ActiveEnumChildLink)
|
.find_also_linked(active_enum::ActiveEnumChildLink)
|
||||||
.all(db)
|
.all(db)
|
||||||
.await?,
|
.await?,
|
||||||
@ -485,7 +488,7 @@ pub async fn find_linked_active_enum(db: &DatabaseConnection) -> Result<(), DbEr
|
|||||||
)]
|
)]
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
ActiveEnum::find()
|
ActiveEnumEntity::find()
|
||||||
.find_with_linked(active_enum::ActiveEnumChildLink)
|
.find_with_linked(active_enum::ActiveEnumChildLink)
|
||||||
.all(db)
|
.all(db)
|
||||||
.await?,
|
.await?,
|
||||||
@ -620,7 +623,7 @@ mod tests {
|
|||||||
.join(" ")
|
.join(" ")
|
||||||
);
|
);
|
||||||
|
|
||||||
let _select = ActiveEnum::find().find_also_related(ActiveEnumChild);
|
let _select = ActiveEnumEntity::find().find_also_related(ActiveEnumChild);
|
||||||
#[cfg(any(feature = "sqlx-mysql", feature = "sqlx-sqlite"))]
|
#[cfg(any(feature = "sqlx-mysql", feature = "sqlx-sqlite"))]
|
||||||
{
|
{
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
@ -707,7 +710,7 @@ mod tests {
|
|||||||
.join(" ")
|
.join(" ")
|
||||||
);
|
);
|
||||||
|
|
||||||
let _select = ActiveEnum::find().find_also_linked(active_enum::ActiveEnumChildLink);
|
let _select = ActiveEnumEntity::find().find_also_linked(active_enum::ActiveEnumChildLink);
|
||||||
#[cfg(any(feature = "sqlx-mysql", feature = "sqlx-sqlite"))]
|
#[cfg(any(feature = "sqlx-mysql", feature = "sqlx-sqlite"))]
|
||||||
{
|
{
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -22,11 +22,7 @@ impl TryGetableFromJson for StringVec {}
|
|||||||
|
|
||||||
impl From<StringVec> for Value {
|
impl From<StringVec> for Value {
|
||||||
fn from(source: StringVec) -> Self {
|
fn from(source: StringVec) -> Self {
|
||||||
sea_orm::Value::Json(
|
sea_orm::Value::Json(serde_json::to_value(source).ok().map(std::boxed::Box::new))
|
||||||
serde_json::to_value(&source)
|
|
||||||
.ok()
|
|
||||||
.map(|s| std::boxed::Box::new(s)),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +74,6 @@ pub async fn tear_down(base_url: &str, db_name: &str) {
|
|||||||
format!("DROP DATABASE IF EXISTS \"{db_name}\";"),
|
format!("DROP DATABASE IF EXISTS \"{db_name}\";"),
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
} else {
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,9 +2,7 @@ pub mod common;
|
|||||||
|
|
||||||
pub use common::{features::*, setup::*, TestContext};
|
pub use common::{features::*, setup::*, TestContext};
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
use sea_orm::{
|
use sea_orm::{entity::prelude::*, DerivePartialModel, FromQueryResult, QuerySelect, Set};
|
||||||
entity::prelude::*, DerivePartialModel, FromQueryResult, QueryOrder, QuerySelect, Set,
|
|
||||||
};
|
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
|
|
||||||
#[sea_orm_macros::test]
|
#[sea_orm_macros::test]
|
||||||
@ -18,7 +16,7 @@ async fn main() -> Result<(), DbErr> {
|
|||||||
create_tables(&ctx.db).await?;
|
create_tables(&ctx.db).await?;
|
||||||
create_insert_default(&ctx.db).await?;
|
create_insert_default(&ctx.db).await?;
|
||||||
cursor_pagination(&ctx.db).await?;
|
cursor_pagination(&ctx.db).await?;
|
||||||
schema::create_tables(&ctx.db).await?;
|
bakery_chain_schema::create_tables(&ctx.db).await?;
|
||||||
create_baker_cake(&ctx.db).await?;
|
create_baker_cake(&ctx.db).await?;
|
||||||
cursor_related_pagination(&ctx.db).await?;
|
cursor_related_pagination(&ctx.db).await?;
|
||||||
ctx.delete().await;
|
ctx.delete().await;
|
||||||
@ -281,7 +279,8 @@ pub async fn cursor_pagination(db: &DatabaseConnection) -> Result<(), DbErr> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
use common::bakery_chain::{
|
use common::bakery_chain::{
|
||||||
baker, bakery, cake, cakes_bakers, schema, Baker, Bakery, Cake, CakesBakers,
|
baker, bakery, cake, cakes_bakers, schema as bakery_chain_schema, Baker, Bakery, Cake,
|
||||||
|
CakesBakers,
|
||||||
};
|
};
|
||||||
|
|
||||||
fn bakery(i: i32) -> bakery::Model {
|
fn bakery(i: i32) -> bakery::Model {
|
||||||
@ -318,8 +317,6 @@ fn cakebaker(cake: char, baker: char) -> CakeBakerlite {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn create_baker_cake(db: &DatabaseConnection) -> Result<(), DbErr> {
|
pub async fn create_baker_cake(db: &DatabaseConnection) -> Result<(), DbErr> {
|
||||||
use sea_orm::IntoActiveModel;
|
|
||||||
|
|
||||||
let mut bakeries: Vec<bakery::ActiveModel> = vec![];
|
let mut bakeries: Vec<bakery::ActiveModel> = vec![];
|
||||||
// bakeries named from 1 to 10
|
// bakeries named from 1 to 10
|
||||||
for i in 1..=10 {
|
for i in 1..=10 {
|
||||||
|
@ -9,7 +9,6 @@ pub use sea_orm::{
|
|||||||
pub use crud::*;
|
pub use crud::*;
|
||||||
// use common::bakery_chain::*;
|
// use common::bakery_chain::*;
|
||||||
use sea_orm::{DbConn, TryInsertResult};
|
use sea_orm::{DbConn, TryInsertResult};
|
||||||
use sea_query::OnConflict;
|
|
||||||
|
|
||||||
#[sea_orm_macros::test]
|
#[sea_orm_macros::test]
|
||||||
#[cfg(any(
|
#[cfg(any(
|
||||||
@ -38,7 +37,7 @@ pub async fn test(db: &DbConn) {
|
|||||||
|
|
||||||
assert!(matches!(res, Ok(TryInsertResult::Inserted(_))));
|
assert!(matches!(res, Ok(TryInsertResult::Inserted(_))));
|
||||||
|
|
||||||
let double_seaside_bakery = bakery::ActiveModel {
|
let _double_seaside_bakery = bakery::ActiveModel {
|
||||||
name: Set("SeaSide Bakery".to_owned()),
|
name: Set("SeaSide Bakery".to_owned()),
|
||||||
profit_margin: Set(10.4),
|
profit_margin: Set(10.4),
|
||||||
id: Set(1),
|
id: Set(1),
|
||||||
|
@ -79,7 +79,7 @@ async fn main() -> Result<(), DbErr> {
|
|||||||
should_panic(expected = "Database backend doesn't support RETURNING")
|
should_panic(expected = "Database backend doesn't support RETURNING")
|
||||||
)]
|
)]
|
||||||
async fn update_many() {
|
async fn update_many() {
|
||||||
pub use common::{features::*, setup::*, TestContext};
|
pub use common::{features::*, TestContext};
|
||||||
use edit_log::*;
|
use edit_log::*;
|
||||||
|
|
||||||
let run = || async {
|
let run = || async {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user