Entity attr as "table"

This commit is contained in:
Chris Tsang 2021-05-17 19:55:46 +08:00
parent 62b3c37e20
commit 682d2151fc
6 changed files with 6 additions and 6 deletions

View File

@ -1,7 +1,7 @@
use sea_orm::entity::prelude::*;
#[derive(Copy, Clone, Default, Debug, DeriveEntity)]
#[entity = "cake"]
#[table = "cake"]
pub struct Entity;
#[derive(Clone, Debug, Default, PartialEq, DeriveModel)]

View File

@ -1,7 +1,7 @@
use sea_orm::entity::prelude::*;
#[derive(Copy, Clone, Default, Debug, DeriveEntity)]
#[entity = "fruit"]
#[table = "fruit"]
pub struct Entity;
#[derive(Clone, Debug, Default, PartialEq, DeriveModel)]

View File

@ -9,7 +9,7 @@ fn get_entity_attr(attrs: &[Attribute]) -> Option<syn::Lit> {
Ok(Meta::NameValue(nv)) => nv,
_ => continue,
};
if name_value.path.is_ident("entity") {
if name_value.path.is_ident("table") {
return Some(name_value.lit);
}
}

View File

@ -5,7 +5,7 @@ use syn::{parse_macro_input, DeriveInput};
mod derives;
#[proc_macro_derive(DeriveEntity, attributes(entity))]
#[proc_macro_derive(DeriveEntity, attributes(table))]
pub fn derive_entity(input: TokenStream) -> TokenStream {
let DeriveInput { ident, attrs, .. } = parse_macro_input!(input);

View File

@ -1,7 +1,7 @@
use crate::entity::prelude::*;
#[derive(Copy, Clone, Default, Debug, DeriveEntity)]
#[entity = "cake"]
#[table = "cake"]
pub struct Entity;
#[derive(Clone, Debug, Default, PartialEq, DeriveModel)]

View File

@ -1,7 +1,7 @@
use crate::entity::prelude::*;
#[derive(Copy, Clone, Default, Debug, DeriveEntity)]
#[entity = "fruit"]
#[table = "fruit"]
pub struct Entity;
#[derive(Clone, Debug, Default, PartialEq, DeriveModel)]