Fix clippy warnings - 1 (#967)

* Fix clippy warnings

* cargo fmt

* Fix clippy warnings

* cargo fmt
This commit is contained in:
Billy Chan 2022-08-12 20:02:53 +08:00 committed by GitHub
parent 0d94941c3b
commit 43495de0aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
58 changed files with 107 additions and 85 deletions

25
build-tools/rustclippy.sh Normal file
View File

@ -0,0 +1,25 @@
#!/bin/bash
set -e
if [ -d ./build-tools ]; then
targets=(
"Cargo.toml"
"sea-orm-cli/Cargo.toml"
"sea-orm-codegen/Cargo.toml"
"sea-orm-macros/Cargo.toml"
"sea-orm-migration/Cargo.toml"
"sea-orm-rocket/Cargo.toml"
)
for target in "${targets[@]}"; do
echo "cargo clippy --manifest-path ${target} --fix --allow-dirty --allow-staged"
cargo clippy --manifest-path "${target}" --fix --allow-dirty --allow-staged
done
examples=(`find examples -type f -name 'Cargo.toml'`)
for example in "${examples[@]}"; do
echo "cargo clippy --manifest-path ${example} --fix --allow-dirty --allow-staged"
cargo clippy --manifest-path "${example}" --fix --allow-dirty --allow-staged
done
else
echo "Please execute this script from the repository root."
fi

View File

@ -1,7 +1,7 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Deserialize, Serialize)] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Deserialize, Serialize)]
#[sea_orm(table_name = "posts")] #[sea_orm(table_name = "posts")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key)] #[sea_orm(primary_key)]

View File

@ -1,7 +1,7 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Deserialize, Serialize)] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Deserialize, Serialize)]
#[sea_orm(table_name = "posts")] #[sea_orm(table_name = "posts")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key)] #[sea_orm(primary_key)]

View File

@ -3,7 +3,7 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(table_name = "posts")] #[sea_orm(table_name = "posts")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key)] #[sea_orm(primary_key)]

View File

@ -1,6 +1,6 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "cake")] #[sea_orm(table_name = "cake")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key)] #[sea_orm(primary_key)]

View File

@ -9,7 +9,7 @@ impl EntityName for Entity {
} }
} }
#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel)] #[derive(Clone, Debug, PartialEq, Eq, DeriveModel, DeriveActiveModel)]
pub struct Model { pub struct Model {
pub cake_id: i32, pub cake_id: i32,
pub filling_id: i32, pub filling_id: i32,

View File

@ -9,7 +9,7 @@ impl EntityName for Entity {
} }
} }
#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel)] #[derive(Clone, Debug, PartialEq, Eq, DeriveModel, DeriveActiveModel)]
pub struct Model { pub struct Model {
pub id: i32, pub id: i32,
pub name: String, pub name: String,

View File

@ -9,7 +9,7 @@ impl EntityName for Entity {
} }
} }
#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel)] #[derive(Clone, Debug, PartialEq, Eq, DeriveModel, DeriveActiveModel)]
pub struct Model { pub struct Model {
pub id: i32, pub id: i32,
pub name: String, pub name: String,

View File

@ -71,7 +71,7 @@ mod form {
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive( #[derive(
Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, DeriveActiveModelBehavior, Clone, Debug, PartialEq, Eq, DeriveModel, DeriveActiveModel, DeriveActiveModelBehavior,
)] )]
pub struct Model { pub struct Model {
pub id: i32, pub id: i32,

View File

@ -28,15 +28,15 @@ pub async fn all_about_select(db: &DbConn) -> Result<(), DbErr> {
println!("===== =====\n"); println!("===== =====\n");
find_all_stream(&db).await.unwrap(); find_all_stream(db).await.unwrap();
println!("===== =====\n"); println!("===== =====\n");
find_first_page(&db).await.unwrap(); find_first_page(db).await.unwrap();
println!("===== =====\n"); println!("===== =====\n");
find_num_pages(&db).await.unwrap(); find_num_pages(db).await.unwrap();
Ok(()) Ok(())
} }
@ -180,15 +180,15 @@ async fn find_many_to_many(db: &DbConn) -> Result<(), DbErr> {
} }
async fn all_about_select_json(db: &DbConn) -> Result<(), DbErr> { async fn all_about_select_json(db: &DbConn) -> Result<(), DbErr> {
find_all_json(&db).await?; find_all_json(db).await?;
println!("===== =====\n"); println!("===== =====\n");
find_together_json(&db).await?; find_together_json(db).await?;
println!("===== =====\n"); println!("===== =====\n");
count_fruits_by_cake_json(&db).await?; count_fruits_by_cake_json(db).await?;
Ok(()) Ok(())
} }

View File

@ -2,7 +2,7 @@ use async_graphql::*;
use sea_orm::{entity::prelude::*, DeleteMany}; use sea_orm::{entity::prelude::*, DeleteMany};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize, SimpleObject)] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Serialize, Deserialize, SimpleObject)]
#[sea_orm(table_name = "notes")] #[sea_orm(table_name = "notes")]
#[graphql(concrete(name = "Note", params()))] #[graphql(concrete(name = "Note", params()))]
pub struct Model { pub struct Model {

View File

@ -1,5 +1,4 @@
use sea_orm_migration::prelude::*; use sea_orm_migration::prelude::*;
use std::path::PathBuf;
#[cfg(debug_assertions)] #[cfg(debug_assertions)]
use dotenv::dotenv; use dotenv::dotenv;

View File

@ -1,7 +1,7 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Deserialize, Serialize)] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Deserialize, Serialize)]
#[sea_orm(table_name = "posts")] #[sea_orm(table_name = "posts")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key)] #[sea_orm(primary_key)]

View File

@ -1,7 +1,7 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Deserialize, Serialize)] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Deserialize, Serialize)]
#[sea_orm(table_name = "posts")] #[sea_orm(table_name = "posts")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key)] #[sea_orm(primary_key)]

View File

@ -1,7 +1,7 @@
use rocket::serde::{Deserialize, Serialize}; use rocket::serde::{Deserialize, Serialize};
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Deserialize, Serialize, FromForm)] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Deserialize, Serialize, FromForm)]
#[serde(crate = "rocket::serde")] #[serde(crate = "rocket::serde")]
#[sea_orm(table_name = "posts")] #[sea_orm(table_name = "posts")]
pub struct Model { pub struct Model {

View File

@ -1,7 +1,7 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Deserialize, Serialize)] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Deserialize, Serialize)]
#[sea_orm(table_name = "posts")] #[sea_orm(table_name = "posts")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key)] #[sea_orm(primary_key)]

View File

@ -1,7 +1,7 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Deserialize, Serialize)] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Deserialize, Serialize)]
#[sea_orm(table_name = "posts")] #[sea_orm(table_name = "posts")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key)] #[sea_orm(primary_key)]

View File

@ -10,7 +10,7 @@ pub struct Cli {
pub command: Commands, pub command: Commands,
} }
#[derive(Subcommand, PartialEq, Debug)] #[derive(Subcommand, PartialEq, Eq, Debug)]
pub enum Commands { pub enum Commands {
#[clap(about = "Codegen related commands")] #[clap(about = "Codegen related commands")]
#[clap(arg_required_else_help = true)] #[clap(arg_required_else_help = true)]
@ -35,7 +35,7 @@ pub enum Commands {
}, },
} }
#[derive(Subcommand, PartialEq, Debug)] #[derive(Subcommand, PartialEq, Eq, Debug)]
pub enum MigrateSubcommands { pub enum MigrateSubcommands {
#[clap(about = "Initialize migration directory")] #[clap(about = "Initialize migration directory")]
Init, Init,
@ -81,7 +81,7 @@ pub enum MigrateSubcommands {
}, },
} }
#[derive(Subcommand, PartialEq, Debug)] #[derive(Subcommand, PartialEq, Eq, Debug)]
pub enum GenerateSubcommands { pub enum GenerateSubcommands {
#[clap(about = "Generate entity")] #[clap(about = "Generate entity")]
#[clap(arg_required_else_help = true)] #[clap(arg_required_else_help = true)]
@ -190,7 +190,7 @@ pub enum GenerateSubcommands {
}, },
} }
#[derive(ArgEnum, Copy, Clone, Debug, PartialEq)] #[derive(ArgEnum, Copy, Clone, Debug, PartialEq, Eq)]
pub enum DateTimeCrate { pub enum DateTimeCrate {
Chrono, Chrono,
Time, Time,

View File

@ -21,7 +21,7 @@ pub struct OutputFile {
pub content: String, pub content: String,
} }
#[derive(PartialEq, Debug)] #[derive(PartialEq, Eq, Debug)]
pub enum WithSerde { pub enum WithSerde {
None, None,
Serialize, Serialize,

View File

@ -12,7 +12,7 @@ use sea_schema::{mysql::MySql, postgres::Postgres, probe::SchemaProbe, sqlite::S
use super::{seaql_migrations, MigrationTrait, SchemaManager}; use super::{seaql_migrations, MigrationTrait, SchemaManager};
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
/// Status of migration /// Status of migration
pub enum MigrationStatus { pub enum MigrationStatus {
/// Not yet applied /// Not yet applied

View File

@ -1,6 +1,6 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "seaql_migrations")] #[sea_orm(table_name = "seaql_migrations")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View File

@ -34,7 +34,7 @@ impl MigrationTrait for Migration {
mod cake { mod cake {
use sea_orm_migration::sea_orm::entity::prelude::*; use sea_orm_migration::sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "cake")] #[sea_orm(table_name = "cake")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key)] #[sea_orm(primary_key)]

View File

@ -47,7 +47,7 @@ use rocket::serde::{Deserialize, Serialize};
/// For general information on configuration in Rocket, see [`rocket::config`]. /// For general information on configuration in Rocket, see [`rocket::config`].
/// For higher-level details on configuring a database, see the [crate-level /// For higher-level details on configuring a database, see the [crate-level
/// docs](crate#configuration). /// docs](crate#configuration).
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(crate = "rocket::serde")] #[serde(crate = "rocket::serde")]
pub struct Config { pub struct Config {
/// Database-specific connection and configuration URL. /// Database-specific connection and configuration URL.

View File

@ -38,7 +38,7 @@ pub type DbConn = DatabaseConnection;
/// The type of database backend for real world databases. /// The type of database backend for real world databases.
/// This is enabled by feature flags as specified in the crate documentation /// This is enabled by feature flags as specified in the crate documentation
#[derive(Debug, Copy, Clone, PartialEq)] #[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum DatabaseBackend { pub enum DatabaseBackend {
/// A MySQL backend /// A MySQL backend
MySql, MySql,

View File

@ -349,7 +349,7 @@ mod tests {
}; };
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
pub struct MyErr(String); pub struct MyErr(String);
impl std::error::Error for MyErr {} impl std::error::Error for MyErr {}

View File

@ -139,7 +139,7 @@ mod tests {
#[test] #[test]
fn active_enum_string() { fn active_enum_string() {
#[derive(Debug, PartialEq, EnumIter)] #[derive(Debug, PartialEq, Eq, EnumIter)]
pub enum Category { pub enum Category {
Big, Big,
Small, Small,
@ -176,7 +176,7 @@ mod tests {
} }
} }
#[derive(Debug, PartialEq, EnumIter, DeriveActiveEnum)] #[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[sea_orm( #[sea_orm(
rs_type = "String", rs_type = "String",
db_type = "String(Some(1))", db_type = "String(Some(1))",
@ -234,7 +234,7 @@ mod tests {
fn active_enum_derive_signed_integers() { fn active_enum_derive_signed_integers() {
macro_rules! test_num_value_int { macro_rules! test_num_value_int {
($ident: ident, $rs_type: expr, $db_type: expr, $col_def: ident) => { ($ident: ident, $rs_type: expr, $db_type: expr, $col_def: ident) => {
#[derive(Debug, PartialEq, EnumIter, DeriveActiveEnum)] #[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[sea_orm(rs_type = $rs_type, db_type = $db_type)] #[sea_orm(rs_type = $rs_type, db_type = $db_type)]
pub enum $ident { pub enum $ident {
#[sea_orm(num_value = -10)] #[sea_orm(num_value = -10)]
@ -251,7 +251,7 @@ mod tests {
macro_rules! test_fallback_int { macro_rules! test_fallback_int {
($ident: ident, $fallback_type: ident, $rs_type: expr, $db_type: expr, $col_def: ident) => { ($ident: ident, $fallback_type: ident, $rs_type: expr, $db_type: expr, $col_def: ident) => {
#[derive(Debug, PartialEq, EnumIter, DeriveActiveEnum)] #[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[sea_orm(rs_type = $rs_type, db_type = $db_type)] #[sea_orm(rs_type = $rs_type, db_type = $db_type)]
#[repr(i32)] #[repr(i32)]
pub enum $ident { pub enum $ident {
@ -300,7 +300,7 @@ mod tests {
fn active_enum_derive_unsigned_integers() { fn active_enum_derive_unsigned_integers() {
macro_rules! test_num_value_uint { macro_rules! test_num_value_uint {
($ident: ident, $rs_type: expr, $db_type: expr, $col_def: ident) => { ($ident: ident, $rs_type: expr, $db_type: expr, $col_def: ident) => {
#[derive(Debug, PartialEq, EnumIter, DeriveActiveEnum)] #[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[sea_orm(rs_type = $rs_type, db_type = $db_type)] #[sea_orm(rs_type = $rs_type, db_type = $db_type)]
pub enum $ident { pub enum $ident {
#[sea_orm(num_value = 1)] #[sea_orm(num_value = 1)]
@ -315,7 +315,7 @@ mod tests {
macro_rules! test_fallback_uint { macro_rules! test_fallback_uint {
($ident: ident, $fallback_type: ident, $rs_type: expr, $db_type: expr, $col_def: ident) => { ($ident: ident, $fallback_type: ident, $rs_type: expr, $db_type: expr, $col_def: ident) => {
#[derive(Debug, PartialEq, EnumIter, DeriveActiveEnum)] #[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[sea_orm(rs_type = $rs_type, db_type = $db_type)] #[sea_orm(rs_type = $rs_type, db_type = $db_type)]
#[repr($fallback_type)] #[repr($fallback_type)]
pub enum $ident { pub enum $ident {

View File

@ -872,7 +872,7 @@ mod tests {
use crate as sea_orm; use crate as sea_orm;
use crate::entity::prelude::*; use crate::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "hello")] #[sea_orm(table_name = "hello")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key)] #[sea_orm(primary_key)]
@ -898,7 +898,7 @@ mod tests {
use crate as sea_orm; use crate as sea_orm;
use crate::entity::prelude::*; use crate::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "hello", schema_name = "world")] #[sea_orm(table_name = "hello", schema_name = "world")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key)] #[sea_orm(primary_key)]

View File

@ -13,7 +13,7 @@ pub struct ColumnDef {
} }
/// The type of column as defined in the SQL format /// The type of column as defined in the SQL format
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub enum ColumnType { pub enum ColumnType {
/// `CHAR` type of specified fixed length /// `CHAR` type of specified fixed length
Char(Option<u32>), Char(Option<u32>),
@ -534,7 +534,7 @@ mod tests {
use crate as sea_orm; use crate as sea_orm;
use crate::entity::prelude::*; use crate::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "hello")] #[sea_orm(table_name = "hello")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key)] #[sea_orm(primary_key)]
@ -608,7 +608,7 @@ mod tests {
use crate as sea_orm; use crate as sea_orm;
use crate::entity::prelude::*; use crate::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "hello")] #[sea_orm(table_name = "hello")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key)] #[sea_orm(primary_key)]
@ -649,7 +649,7 @@ mod tests {
} }
} }
#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel)] #[derive(Clone, Debug, PartialEq, Eq, DeriveModel, DeriveActiveModel)]
pub struct Model { pub struct Model {
pub id: i32, pub id: i32,
pub one: i32, pub one: i32,
@ -713,7 +713,7 @@ mod tests {
use crate as sea_orm; use crate as sea_orm;
use crate::entity::prelude::*; use crate::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "hello")] #[sea_orm(table_name = "hello")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key)] #[sea_orm(primary_key)]
@ -754,7 +754,7 @@ mod tests {
} }
} }
#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel)] #[derive(Clone, Debug, PartialEq, Eq, DeriveModel, DeriveActiveModel)]
pub struct Model { pub struct Model {
pub id: i32, pub id: i32,
#[sea_orm(enum_name = "One1")] #[sea_orm(enum_name = "One1")]
@ -819,7 +819,7 @@ mod tests {
use crate as sea_orm; use crate as sea_orm;
use crate::entity::prelude::*; use crate::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "hello")] #[sea_orm(table_name = "hello")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, column_name = "ID", enum_name = "IdentityColumn")] #[sea_orm(primary_key, column_name = "ID", enum_name = "IdentityColumn")]
@ -861,7 +861,7 @@ mod tests {
} }
} }
#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel)] #[derive(Clone, Debug, PartialEq, Eq, DeriveModel, DeriveActiveModel)]
pub struct Model { pub struct Model {
#[sea_orm(enum_name = "IdentityCol")] #[sea_orm(enum_name = "IdentityCol")]
pub id: i32, pub id: i32,
@ -930,7 +930,7 @@ mod tests {
use crate as sea_orm; use crate as sea_orm;
use crate::entity::prelude::*; use crate::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "my_entity")] #[sea_orm(table_name = "my_entity")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, enum_name = "IdentityColumn", column_name = "id")] #[sea_orm(primary_key, enum_name = "IdentityColumn", column_name = "id")]

View File

@ -11,7 +11,7 @@ pub struct Deleter {
} }
/// The result of a DELETE operation /// The result of a DELETE operation
#[derive(Clone, Debug, PartialEq)] #[derive(Clone, Debug, PartialEq, Eq)]
pub struct DeleteResult { pub struct DeleteResult {
/// The number of rows affected by the DELETE operation /// The number of rows affected by the DELETE operation
pub rows_affected: u64, pub rows_affected: u64,

View File

@ -13,7 +13,7 @@ pub struct Updater {
} }
/// The result of an update operation on an ActiveModel /// The result of an update operation on an ActiveModel
#[derive(Clone, Debug, PartialEq)] #[derive(Clone, Debug, PartialEq, Eq)]
pub struct UpdateResult { pub struct UpdateResult {
/// The rows affected by the update operation /// The rows affected by the update operation
pub rows_affected: u64, pub rows_affected: u64,

View File

@ -4,7 +4,7 @@ use crate::entity::prelude::*;
#[cfg(feature = "with-json")] #[cfg(feature = "with-json")]
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[cfg_attr(feature = "with-json", derive(Serialize, Deserialize))] #[cfg_attr(feature = "with-json", derive(Serialize, Deserialize))]
#[sea_orm(table_name = "cake")] #[sea_orm(table_name = "cake")]
pub struct Model { pub struct Model {

View File

@ -10,7 +10,7 @@ impl EntityName for Entity {
} }
} }
#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel)] #[derive(Clone, Debug, PartialEq, Eq, DeriveModel, DeriveActiveModel)]
pub struct Model { pub struct Model {
pub id: i32, pub id: i32,
pub name: String, pub name: String,

View File

@ -10,7 +10,7 @@ impl EntityName for Entity {
} }
} }
#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel)] #[derive(Clone, Debug, PartialEq, Eq, DeriveModel, DeriveActiveModel)]
pub struct Model { pub struct Model {
pub cake_id: i32, pub cake_id: i32,
pub filling_id: i32, pub filling_id: i32,

View File

@ -14,7 +14,7 @@ impl EntityName for Entity {
} }
} }
#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel)] #[derive(Clone, Debug, PartialEq, Eq, DeriveModel, DeriveActiveModel)]
pub struct Model { pub struct Model {
pub cake_id: i32, pub cake_id: i32,
pub filling_id: i32, pub filling_id: i32,

View File

@ -5,7 +5,7 @@ use crate::entity::prelude::*;
#[sea_orm(table_name = "filling")] #[sea_orm(table_name = "filling")]
pub struct Entity; pub struct Entity;
#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel)] #[derive(Clone, Debug, PartialEq, Eq, DeriveModel, DeriveActiveModel)]
pub struct Model { pub struct Model {
pub id: i32, pub id: i32,
pub name: String, pub name: String,

View File

@ -4,7 +4,7 @@ use crate::entity::prelude::*;
#[cfg(feature = "with-json")] #[cfg(feature = "with-json")]
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[cfg_attr(feature = "with-json", derive(Serialize, Deserialize))] #[cfg_attr(feature = "with-json", derive(Serialize, Deserialize))]
#[sea_orm(table_name = "fruit")] #[sea_orm(table_name = "fruit")]
pub struct Model { pub struct Model {

View File

@ -15,7 +15,7 @@ impl EntityName for Entity {
} }
} }
#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel)] #[derive(Clone, Debug, PartialEq, Eq, DeriveModel, DeriveActiveModel)]
pub struct Model { pub struct Model {
pub indexes_id: i32, pub indexes_id: i32,
pub unique_attr: i32, pub unique_attr: i32,

View File

@ -1,7 +1,7 @@
use crate as sea_orm; use crate as sea_orm;
use crate::entity::prelude::*; use crate::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "rust_keyword")] #[sea_orm(table_name = "rust_keyword")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key)] #[sea_orm(primary_key)]

View File

@ -1,7 +1,7 @@
use crate as sea_orm; use crate as sea_orm;
use crate::entity::prelude::*; use crate::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "vendor")] #[sea_orm(table_name = "vendor")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key)] #[sea_orm(primary_key)]

View File

@ -1,6 +1,6 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "baker")] #[sea_orm(table_name = "baker")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key)] #[sea_orm(primary_key)]

View File

@ -1,6 +1,6 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "cake")] #[sea_orm(table_name = "cake")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key)] #[sea_orm(primary_key)]

View File

@ -1,6 +1,6 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "cakes_bakers")] #[sea_orm(table_name = "cakes_bakers")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key)] #[sea_orm(primary_key)]

View File

@ -1,6 +1,6 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "customer")] #[sea_orm(table_name = "customer")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key)] #[sea_orm(primary_key)]

View File

@ -1,6 +1,6 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "lineitem")] #[sea_orm(table_name = "lineitem")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key)] #[sea_orm(primary_key)]

View File

@ -1,6 +1,6 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "order")] #[sea_orm(table_name = "order")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key)] #[sea_orm(primary_key)]

View File

@ -1,7 +1,7 @@
use super::sea_orm_active_enums::*; use super::sea_orm_active_enums::*;
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[cfg_attr(feature = "sqlx-postgres", sea_orm(schema_name = "public"))] #[cfg_attr(feature = "sqlx-postgres", sea_orm(schema_name = "public"))]
#[sea_orm(table_name = "active_enum")] #[sea_orm(table_name = "active_enum")]
pub struct Model { pub struct Model {

View File

@ -1,7 +1,7 @@
use super::sea_orm_active_enums::*; use super::sea_orm_active_enums::*;
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[cfg_attr(feature = "sqlx-postgres", sea_orm(schema_name = "public"))] #[cfg_attr(feature = "sqlx-postgres", sea_orm(schema_name = "public"))]
#[sea_orm(table_name = "active_enum_child")] #[sea_orm(table_name = "active_enum_child")]
pub struct Model { pub struct Model {

View File

@ -1,6 +1,6 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "applog")] #[sea_orm(table_name = "applog")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key)] #[sea_orm(primary_key)]

View File

@ -1,6 +1,6 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "byte_primary_key")] #[sea_orm(table_name = "byte_primary_key")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View File

@ -1,6 +1,6 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "insert_default")] #[sea_orm(table_name = "insert_default")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key)] #[sea_orm(primary_key)]

View File

@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*;
use sea_orm::{TryGetError, TryGetable}; use sea_orm::{TryGetError, TryGetable};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "json_vec")] #[sea_orm(table_name = "json_vec")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key)] #[sea_orm(primary_key)]
@ -15,7 +15,7 @@ pub enum Relation {}
impl ActiveModelBehavior for ActiveModel {} impl ActiveModelBehavior for ActiveModel {}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct StringVec(pub Vec<String>); pub struct StringVec(pub Vec<String>);
impl From<StringVec> for Value { impl From<StringVec> for Value {

View File

@ -1,6 +1,6 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "metadata")] #[sea_orm(table_name = "metadata")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View File

@ -1,6 +1,6 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "repository")] #[sea_orm(table_name = "repository")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View File

@ -1,6 +1,6 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "satellite")] #[sea_orm(table_name = "satellite")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key)] #[sea_orm(primary_key)]

View File

@ -1,6 +1,6 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Debug, Clone, PartialEq, EnumIter, DeriveActiveEnum)] #[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[sea_orm(rs_type = "String", db_type = "String(Some(1))")] #[sea_orm(rs_type = "String", db_type = "String(Some(1))")]
pub enum Category { pub enum Category {
#[sea_orm(string_value = "B")] #[sea_orm(string_value = "B")]
@ -9,7 +9,7 @@ pub enum Category {
Small, Small,
} }
#[derive(Debug, Clone, PartialEq, EnumIter, DeriveActiveEnum)] #[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[sea_orm(rs_type = "i32", db_type = "Integer")] #[sea_orm(rs_type = "i32", db_type = "Integer")]
pub enum Color { pub enum Color {
#[sea_orm(num_value = 0)] #[sea_orm(num_value = 0)]
@ -18,7 +18,7 @@ pub enum Color {
White, White,
} }
#[derive(Debug, Clone, PartialEq, EnumIter, DeriveActiveEnum)] #[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "tea")] #[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "tea")]
pub enum Tea { pub enum Tea {
#[sea_orm(string_value = "EverydayTea")] #[sea_orm(string_value = "EverydayTea")]

View File

@ -1,6 +1,6 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "self_join")] #[sea_orm(table_name = "self_join")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View File

@ -1,6 +1,6 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "transaction_log")] #[sea_orm(table_name = "transaction_log")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key)] #[sea_orm(primary_key)]

View File

@ -9,7 +9,7 @@ use sea_query::{
}; };
pub async fn setup(base_url: &str, db_name: &str) -> DatabaseConnection { pub async fn setup(base_url: &str, db_name: &str) -> DatabaseConnection {
let db = if cfg!(feature = "sqlx-mysql") { if cfg!(feature = "sqlx-mysql") {
let url = format!("{}/mysql", base_url); let url = format!("{}/mysql", base_url);
let db = Database::connect(&url).await.unwrap(); let db = Database::connect(&url).await.unwrap();
let _drop_db_result = db let _drop_db_result = db
@ -49,9 +49,7 @@ pub async fn setup(base_url: &str, db_name: &str) -> DatabaseConnection {
Database::connect(&url).await.unwrap() Database::connect(&url).await.unwrap()
} else { } else {
Database::connect(base_url).await.unwrap() Database::connect(base_url).await.unwrap()
}; }
db
} }
pub async fn tear_down(base_url: &str, db_name: &str) { pub async fn tear_down(base_url: &str, db_name: &str) {