Remove sea-query's Iden macro
This commit is contained in:
parent
866025a733
commit
ae899d6744
28
CHANGELOG.md
28
CHANGELOG.md
@ -548,6 +548,34 @@ impl ColumnTrait for Column {
|
|||||||
* Replace the use of `SeaRc<T>` where `T` isn't `dyn Iden` with `RcOrArc<T>` https://github.com/SeaQL/sea-orm/pull/1661
|
* Replace the use of `SeaRc<T>` where `T` isn't `dyn Iden` with `RcOrArc<T>` https://github.com/SeaQL/sea-orm/pull/1661
|
||||||
* Enabled `hashable-value` feature in SeaQuery, thus `Value::Float(NaN) == Value::Float(NaN)` would be true https://github.com/SeaQL/sea-orm/pull/1728, https://github.com/SeaQL/sea-orm/pull/1743
|
* Enabled `hashable-value` feature in SeaQuery, thus `Value::Float(NaN) == Value::Float(NaN)` would be true https://github.com/SeaQL/sea-orm/pull/1728, https://github.com/SeaQL/sea-orm/pull/1743
|
||||||
* The `DeriveActiveEnum` derive macro no longer provide `std::fmt::Display` implementation for the enum. You need to derive an extra `DeriveDisplay` macro alongside with `DeriveActiveEnum` derive macro. https://github.com/SeaQL/sea-orm/pull/1726
|
* The `DeriveActiveEnum` derive macro no longer provide `std::fmt::Display` implementation for the enum. You need to derive an extra `DeriveDisplay` macro alongside with `DeriveActiveEnum` derive macro. https://github.com/SeaQL/sea-orm/pull/1726
|
||||||
|
* `sea-query/derive` is no longer enabled by `sea-orm`, as such, `Iden` no longer works as a derive macro (it's still a trait). Instead, we are shipping a new macro `DeriveIden`:
|
||||||
|
```rust
|
||||||
|
// then:
|
||||||
|
|
||||||
|
#[derive(Iden)]
|
||||||
|
#[iden = "category"]
|
||||||
|
pub struct CategoryEnum;
|
||||||
|
|
||||||
|
#[derive(Iden)]
|
||||||
|
pub enum Tea {
|
||||||
|
Table,
|
||||||
|
#[iden = "EverydayTea"]
|
||||||
|
EverydayTea,
|
||||||
|
}
|
||||||
|
|
||||||
|
// now:
|
||||||
|
|
||||||
|
#[derive(DeriveIden)]
|
||||||
|
#[sea_orm(iden = "category")]
|
||||||
|
pub struct CategoryEnum;
|
||||||
|
|
||||||
|
#[derive(DeriveIden)]
|
||||||
|
pub enum Tea {
|
||||||
|
Table,
|
||||||
|
#[sea_orm(iden = "EverydayTea")]
|
||||||
|
EverydayTea,
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## 0.11.3 - 2023-04-24
|
## 0.11.3 - 2023-04-24
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ tracing = { version = "0.1", default-features = false, features = ["attributes",
|
|||||||
rust_decimal = { version = "1", default-features = false, optional = true }
|
rust_decimal = { version = "1", default-features = false, optional = true }
|
||||||
bigdecimal = { version = "0.3", default-features = false, optional = true }
|
bigdecimal = { version = "0.3", default-features = false, optional = true }
|
||||||
sea-orm-macros = { version = "0.12.0-rc.4", path = "sea-orm-macros", default-features = false, features = ["strum"] }
|
sea-orm-macros = { version = "0.12.0-rc.4", path = "sea-orm-macros", default-features = false, features = ["strum"] }
|
||||||
sea-query = { version = "0.29.0", features = ["thread-safe", "hashable-value"] }
|
sea-query = { version = "0.29.0", default-features = false, features = ["thread-safe", "hashable-value", "backend-mysql", "backend-postgres", "backend-sqlite"] }
|
||||||
sea-query-binder = { version = "0.4.0-rc.2", default-features = false, optional = true }
|
sea-query-binder = { version = "0.4.0-rc.2", default-features = false, optional = true }
|
||||||
strum = { version = "0.25", default-features = false }
|
strum = { version = "0.25", default-features = false }
|
||||||
serde = { version = "1.0", default-features = false }
|
serde = { version = "1.0", default-features = false }
|
||||||
@ -74,7 +74,7 @@ default = [
|
|||||||
"with-uuid",
|
"with-uuid",
|
||||||
"with-time",
|
"with-time",
|
||||||
]
|
]
|
||||||
macros = ["sea-orm-macros/derive", "sea-query/derive"]
|
macros = ["sea-orm-macros/derive"]
|
||||||
mock = []
|
mock = []
|
||||||
with-json = ["serde_json", "sea-query/with-json", "chrono?/serde", "time?/serde", "uuid?/serde", "sea-query-binder?/with-json", "sqlx?/json"]
|
with-json = ["serde_json", "sea-query/with-json", "chrono?/serde", "time?/serde", "uuid?/serde", "sea-query-binder?/with-json", "sqlx?/json"]
|
||||||
with-chrono = ["chrono", "sea-query/with-chrono", "sea-query-binder?/with-chrono", "sqlx?/chrono"]
|
with-chrono = ["chrono", "sea-query/with-chrono", "sea-query-binder?/with-chrono", "sqlx?/chrono"]
|
||||||
|
@ -32,8 +32,7 @@ impl MigrationTrait for Migration {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Learn more at https://docs.rs/sea-query#iden
|
#[derive(DeriveIden)]
|
||||||
#[derive(Iden)]
|
|
||||||
enum Posts {
|
enum Posts {
|
||||||
Table,
|
Table,
|
||||||
Id,
|
Id,
|
||||||
|
@ -32,8 +32,7 @@ impl MigrationTrait for Migration {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Learn more at https://docs.rs/sea-query#iden
|
#[derive(DeriveIden)]
|
||||||
#[derive(Iden)]
|
|
||||||
enum Posts {
|
enum Posts {
|
||||||
Table,
|
Table,
|
||||||
Id,
|
Id,
|
||||||
|
@ -32,8 +32,7 @@ impl MigrationTrait for Migration {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Learn more at https://docs.rs/sea-query#iden
|
#[derive(DeriveIden)]
|
||||||
#[derive(Iden)]
|
|
||||||
enum Posts {
|
enum Posts {
|
||||||
Table,
|
Table,
|
||||||
Id,
|
Id,
|
||||||
|
@ -32,8 +32,7 @@ impl MigrationTrait for Migration {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Learn more at https://docs.rs/sea-query#iden
|
#[derive(DeriveIden)]
|
||||||
#[derive(Iden)]
|
|
||||||
enum Notes {
|
enum Notes {
|
||||||
Table,
|
Table,
|
||||||
Id,
|
Id,
|
||||||
|
@ -32,8 +32,7 @@ impl MigrationTrait for Migration {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Learn more at https://docs.rs/sea-query#iden
|
#[derive(DeriveIden)]
|
||||||
#[derive(Iden)]
|
|
||||||
enum Posts {
|
enum Posts {
|
||||||
Table,
|
Table,
|
||||||
Id,
|
Id,
|
||||||
|
@ -32,8 +32,7 @@ impl MigrationTrait for Migration {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Learn more at https://docs.rs/sea-query#iden
|
#[derive(DeriveIden)]
|
||||||
#[derive(Iden)]
|
|
||||||
enum Posts {
|
enum Posts {
|
||||||
Table,
|
Table,
|
||||||
Id,
|
Id,
|
||||||
|
@ -32,8 +32,7 @@ impl MigrationTrait for Migration {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Learn more at https://docs.rs/sea-query#iden
|
#[derive(DeriveIden)]
|
||||||
#[derive(Iden)]
|
|
||||||
enum Posts {
|
enum Posts {
|
||||||
Table,
|
Table,
|
||||||
Id,
|
Id,
|
||||||
|
@ -32,8 +32,7 @@ impl MigrationTrait for Migration {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Learn more at https://docs.rs/sea-query#iden
|
#[derive(DeriveIden)]
|
||||||
#[derive(Iden)]
|
|
||||||
enum Posts {
|
enum Posts {
|
||||||
Table,
|
Table,
|
||||||
Id,
|
Id,
|
||||||
|
@ -32,8 +32,7 @@ impl MigrationTrait for Migration {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Learn more at https://docs.rs/sea-query#iden
|
#[derive(DeriveIden)]
|
||||||
#[derive(Iden)]
|
|
||||||
enum Posts {
|
enum Posts {
|
||||||
Table,
|
Table,
|
||||||
Id,
|
Id,
|
||||||
|
@ -32,8 +32,7 @@ impl MigrationTrait for Migration {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Learn more at https://docs.rs/sea-query#iden
|
#[derive(DeriveIden)]
|
||||||
#[derive(Iden)]
|
|
||||||
enum Posts {
|
enum Posts {
|
||||||
Table,
|
Table,
|
||||||
Id,
|
Id,
|
||||||
|
@ -10,4 +10,4 @@ publish = false
|
|||||||
[dependencies.sea-orm]
|
[dependencies.sea-orm]
|
||||||
path = "../../"
|
path = "../../"
|
||||||
default-features = false
|
default-features = false
|
||||||
features = ["macros", "runtime-tokio-native-tls"]
|
features = ["macros", "runtime-tokio-native-tls"]
|
@ -1,17 +1,16 @@
|
|||||||
use sea_orm::{sea_query::{self, Iden}};
|
use sea_orm::{DeriveIden, Iden};
|
||||||
|
|
||||||
#[derive(Iden)]
|
#[derive(DeriveIden)]
|
||||||
enum Character {
|
enum Character {
|
||||||
Table,
|
Table,
|
||||||
Id,
|
Id,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Iden)]
|
#[derive(DeriveIden)]
|
||||||
struct Glyph;
|
struct Glyph;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
assert_eq!(Character::Table.to_string(), "character");
|
assert_eq!(Character::Table.to_string(), "character");
|
||||||
assert_eq!(Character::Id.to_string(), "id");
|
assert_eq!(Character::Id.to_string(), "id");
|
||||||
|
|
||||||
assert_eq!(Glyph.to_string(), "glyph");
|
assert_eq!(Glyph.to_string(), "glyph");
|
||||||
}
|
}
|
||||||
|
@ -38,8 +38,7 @@ impl MigrationTrait for Migration {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Learn more at https://docs.rs/sea-query#iden
|
#[derive(DeriveIden)]
|
||||||
#[derive(Iden)]
|
|
||||||
enum Post {
|
enum Post {
|
||||||
Table,
|
Table,
|
||||||
Id,
|
Id,
|
||||||
|
@ -6,12 +6,13 @@ use std::time::SystemTime;
|
|||||||
use tracing::info;
|
use tracing::info;
|
||||||
|
|
||||||
use sea_orm::sea_query::{
|
use sea_orm::sea_query::{
|
||||||
self, extension::postgres::Type, Alias, Expr, ForeignKey, Iden, IntoIden, JoinType, Order,
|
self, extension::postgres::Type, Alias, Expr, ForeignKey, IntoIden, JoinType, Order, Query,
|
||||||
Query, SelectStatement, SimpleExpr, Table,
|
SelectStatement, SimpleExpr, Table,
|
||||||
};
|
};
|
||||||
use sea_orm::{
|
use sea_orm::{
|
||||||
ActiveModelTrait, ActiveValue, Condition, ConnectionTrait, DbBackend, DbErr, DynIden,
|
ActiveModelTrait, ActiveValue, Condition, ConnectionTrait, DbBackend, DbErr, DeriveIden,
|
||||||
EntityTrait, FromQueryResult, Iterable, QueryFilter, Schema, Statement, TransactionTrait,
|
DynIden, EntityTrait, FromQueryResult, Iterable, QueryFilter, Schema, Statement,
|
||||||
|
TransactionTrait,
|
||||||
};
|
};
|
||||||
use sea_schema::{mysql::MySql, postgres::Postgres, probe::SchemaProbe, sqlite::Sqlite};
|
use sea_schema::{mysql::MySql, postgres::Postgres, probe::SchemaProbe, sqlite::Sqlite};
|
||||||
|
|
||||||
@ -457,13 +458,13 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Iden)]
|
#[derive(DeriveIden)]
|
||||||
enum InformationSchema {
|
enum InformationSchema {
|
||||||
#[iden = "information_schema"]
|
#[sea_orm(iden = "information_schema")]
|
||||||
Schema,
|
Schema,
|
||||||
#[iden = "TABLE_NAME"]
|
#[sea_orm(iden = "TABLE_NAME")]
|
||||||
TableName,
|
TableName,
|
||||||
#[iden = "CONSTRAINT_NAME"]
|
#[sea_orm(iden = "CONSTRAINT_NAME")]
|
||||||
ConstraintName,
|
ConstraintName,
|
||||||
TableConstraints,
|
TableConstraints,
|
||||||
TableSchema,
|
TableSchema,
|
||||||
@ -500,7 +501,7 @@ where
|
|||||||
stmt
|
stmt
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Iden)]
|
#[derive(DeriveIden)]
|
||||||
enum PgType {
|
enum PgType {
|
||||||
Table,
|
Table,
|
||||||
Typname,
|
Typname,
|
||||||
@ -508,7 +509,7 @@ enum PgType {
|
|||||||
Typelem,
|
Typelem,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Iden)]
|
#[derive(DeriveIden)]
|
||||||
enum PgNamespace {
|
enum PgNamespace {
|
||||||
Table,
|
Table,
|
||||||
Oid,
|
Oid,
|
||||||
|
@ -9,5 +9,5 @@ pub use async_trait;
|
|||||||
pub use sea_orm::{
|
pub use sea_orm::{
|
||||||
self,
|
self,
|
||||||
sea_query::{self, *},
|
sea_query::{self, *},
|
||||||
ConnectionTrait, DbErr, DeriveMigrationName,
|
ConnectionTrait, DbErr, DeriveIden, DeriveMigrationName,
|
||||||
};
|
};
|
||||||
|
@ -38,8 +38,7 @@ impl MigrationTrait for Migration {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Learn more at https://docs.rs/sea-query#iden
|
#[derive(DeriveIden)]
|
||||||
#[derive(Iden)]
|
|
||||||
pub enum Cake {
|
pub enum Cake {
|
||||||
Table,
|
Table,
|
||||||
Id,
|
Id,
|
||||||
|
@ -49,8 +49,7 @@ impl MigrationTrait for Migration {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Learn more at https://docs.rs/sea-query#iden
|
#[derive(DeriveIden)]
|
||||||
#[derive(Iden)]
|
|
||||||
pub enum Fruit {
|
pub enum Fruit {
|
||||||
Table,
|
Table,
|
||||||
Id,
|
Id,
|
||||||
|
@ -42,12 +42,11 @@ impl MigrationTrait for Migration {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Learn more at https://docs.rs/sea-query#iden
|
#[derive(DeriveIden)]
|
||||||
#[derive(Iden)]
|
|
||||||
pub enum Tea {
|
pub enum Tea {
|
||||||
Table,
|
Table,
|
||||||
#[iden = "EverydayTea"]
|
#[sea_orm(iden = "EverydayTea")]
|
||||||
EverydayTea,
|
EverydayTea,
|
||||||
#[iden = "BreakfastTea"]
|
#[sea_orm(iden = "BreakfastTea")]
|
||||||
BreakfastTea,
|
BreakfastTea,
|
||||||
}
|
}
|
||||||
|
@ -29,8 +29,7 @@ impl MigrationTrait for Migration {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Learn more at https://docs.rs/sea-query#iden
|
#[derive(DeriveIden)]
|
||||||
#[derive(Iden)]
|
|
||||||
pub enum Cake {
|
pub enum Cake {
|
||||||
Table,
|
Table,
|
||||||
Name,
|
Name,
|
||||||
|
@ -37,7 +37,7 @@ use sea_query::{DynIden, Expr, Nullable, SimpleExpr, Value, ValueType};
|
|||||||
/// Small,
|
/// Small,
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// #[derive(Debug, Iden)]
|
/// #[derive(Debug, DeriveIden)]
|
||||||
/// pub struct CategoryEnum;
|
/// pub struct CategoryEnum;
|
||||||
///
|
///
|
||||||
/// impl ActiveEnum for Category {
|
/// impl ActiveEnum for Category {
|
||||||
@ -182,8 +182,8 @@ mod tests {
|
|||||||
Small,
|
Small,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Iden)]
|
#[derive(Debug, DeriveIden)]
|
||||||
#[iden = "category"]
|
#[sea_orm(iden = "category")]
|
||||||
pub struct CategoryEnum;
|
pub struct CategoryEnum;
|
||||||
|
|
||||||
impl ActiveEnum for Category {
|
impl ActiveEnum for Category {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::{self as sea_orm, EntityName, IdenStatic, IntoSimpleExpr, Iterable};
|
use crate::{EntityName, Iden, IdenStatic, IntoSimpleExpr, Iterable};
|
||||||
use sea_query::{
|
use sea_query::{
|
||||||
Alias, BinOper, DynIden, Expr, Iden, IntoIden, SeaRc, SelectStatement, SimpleExpr, Value,
|
Alias, BinOper, DynIden, Expr, IntoIden, SeaRc, SelectStatement, SimpleExpr, Value,
|
||||||
};
|
};
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
@ -381,13 +381,21 @@ impl ColumnDef {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Iden)]
|
|
||||||
struct Text;
|
struct Text;
|
||||||
|
|
||||||
#[derive(Iden)]
|
|
||||||
#[iden = "text[]"]
|
|
||||||
struct TextArray;
|
struct TextArray;
|
||||||
|
|
||||||
|
impl Iden for Text {
|
||||||
|
fn unquoted(&self, s: &mut dyn std::fmt::Write) {
|
||||||
|
write!(s, "text").unwrap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Iden for TextArray {
|
||||||
|
fn unquoted(&self, s: &mut dyn std::fmt::Write) {
|
||||||
|
write!(s, "text[]").unwrap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn cast_enum_as<C, F>(expr: Expr, col: &C, f: F) -> SimpleExpr
|
fn cast_enum_as<C, F>(expr: Expr, col: &C, f: F) -> SimpleExpr
|
||||||
where
|
where
|
||||||
C: ColumnTrait,
|
C: ColumnTrait,
|
||||||
|
@ -11,8 +11,9 @@ pub use crate::{
|
|||||||
#[cfg(feature = "macros")]
|
#[cfg(feature = "macros")]
|
||||||
pub use crate::{
|
pub use crate::{
|
||||||
DeriveActiveEnum, DeriveActiveModel, DeriveActiveModelBehavior, DeriveColumn,
|
DeriveActiveEnum, DeriveActiveModel, DeriveActiveModelBehavior, DeriveColumn,
|
||||||
DeriveCustomColumn, DeriveDisplay, DeriveEntity, DeriveEntityModel, DeriveIntoActiveModel,
|
DeriveCustomColumn, DeriveDisplay, DeriveEntity, DeriveEntityModel, DeriveIden,
|
||||||
DeriveModel, DerivePrimaryKey, DeriveRelatedEntity, DeriveRelation, FromJsonQueryResult,
|
DeriveIntoActiveModel, DeriveModel, DerivePrimaryKey, DeriveRelatedEntity, DeriveRelation,
|
||||||
|
FromJsonQueryResult,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub use async_trait;
|
pub use async_trait;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user