MCPcopy Create free account
hub / github.com/SeaQL/sea-orm / impl_entity_name

Method impl_entity_name

sea-orm-macros/src/derives/entity.rs:65–89  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

63 }
64
65 fn impl_entity_name(&self) -> TokenStream {
66 let ident = &self.ident;
67 let table_name = match &self.table_name {
68 Some(table_name) => table_name,
69 None => return TokenStream::new(), // No table name, do not derive EntityName
70 };
71 let expanded_schema_name = self
72 .schema_name
73 .as_ref()
74 .map(|schema| quote!(Some(#schema)))
75 .unwrap_or_else(|| quote!(None));
76
77 quote!(
78 #[automatically_derived]
79 impl sea_orm::entity::EntityName for #ident {
80 fn schema_name(&self) -> Option<&str> {
81 #expanded_schema_name
82 }
83
84 fn table_name(&self) -> &str {
85 #table_name
86 }
87 }
88 )
89 }
90
91 fn impl_entity_trait(&self) -> TokenStream {
92 let Self {

Callers 1

expandMethod · 0.80

Calls 2

as_refMethod · 0.80
newFunction · 0.50

Tested by

no test coverage detected