Caisin 94eac96513
create_table_from_entity support comment (#2009)
* support table and column comment

* create_table_from_entity support comment

* fmt code

* fmt code

* add comment test

* fix test
2023-12-14 18:22:36 +08:00

63 lines
1.7 KiB
Rust

pub mod derive_attr {
use bae::FromAttributes;
/// Attributes for Models and ActiveModels
#[derive(Default, FromAttributes)]
pub struct SeaOrm {
pub column: Option<syn::Ident>,
pub entity: Option<syn::Ident>,
pub model: Option<syn::Ident>,
pub primary_key: Option<syn::Ident>,
pub relation: Option<syn::Ident>,
pub schema_name: Option<syn::Lit>,
pub table_name: Option<syn::Lit>,
pub comment: Option<syn::Lit>,
pub table_iden: Option<()>,
}
}
pub mod field_attr {
use bae::FromAttributes;
/// Operations for Models and ActiveModels
#[derive(Default, FromAttributes)]
pub struct SeaOrm {
pub belongs_to: Option<syn::Lit>,
pub has_one: Option<syn::Lit>,
pub has_many: Option<syn::Lit>,
pub on_update: Option<syn::Lit>,
pub on_delete: Option<syn::Lit>,
pub on_condition: Option<syn::Lit>,
pub from: Option<syn::Lit>,
pub to: Option<syn::Lit>,
pub fk_name: Option<syn::Lit>,
pub condition_type: Option<syn::Lit>,
}
}
pub mod related_attr {
use bae::FromAttributes;
/// Operations for RelatedEntity enumeration
#[derive(Default, FromAttributes)]
pub struct SeaOrm {
///
/// Allows to modify target entity
///
/// Required on enumeration variants
///
/// If used on enumeration attributes
/// it allows to specify different
/// Entity ident
pub entity: Option<syn::Lit>,
///
/// Allows to specify RelationDef
///
/// Optional
///
/// If not supplied the generated code
/// will utilize `impl Related` trait
pub def: Option<syn::Lit>,
}
}