|
@@ -200,6 +200,7 @@ pub fn derive(tokens: proc_macro::TokenStream) -> proc_macro::TokenStream {
|
|
|
let entity_name = entity_ident.to_string().to_case(Case::Snake);
|
|
|
|
|
|
let id_ident = format_ident!("{}ID", entity_ident);
|
|
|
+ let id_part_ident = format_ident!("{}IDPart", entity_ident);
|
|
|
|
|
|
quote! {
|
|
|
#(#part_defs)*
|
|
@@ -219,20 +220,6 @@ pub fn derive(tokens: proc_macro::TokenStream) -> proc_macro::TokenStream {
|
|
|
fn into_raw(self) -> i64 { self.0 }
|
|
|
}
|
|
|
|
|
|
- impl ::microrm::schema::entity::EntityPart for #id_ident {
|
|
|
- type Datum = Self;
|
|
|
- type Entity = #entity_ident;
|
|
|
-
|
|
|
- fn unique() -> bool { false }
|
|
|
- fn part_name() -> &'static str { "id" }
|
|
|
-
|
|
|
- fn desc() -> Option<&'static str> { None }
|
|
|
-
|
|
|
- fn get_datum(from: &Self::Entity) -> &Self::Datum {
|
|
|
- unreachable!()
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
impl ::microrm::schema::datum::Datum for #id_ident {
|
|
|
fn sql_type() -> &'static str {
|
|
|
<i64 as ::microrm::schema::datum::Datum>::sql_type()
|
|
@@ -264,6 +251,23 @@ pub fn derive(tokens: proc_macro::TokenStream) -> proc_macro::TokenStream {
|
|
|
|
|
|
impl ::microrm::schema::datum::ConcreteDatum for #id_ident {}
|
|
|
|
|
|
+ #[derive(Clone, Copy, Default)]
|
|
|
+ #vis struct #id_part_ident;
|
|
|
+
|
|
|
+ impl ::microrm::schema::entity::EntityPart for #id_part_ident {
|
|
|
+ type Datum = #id_ident;
|
|
|
+ type Entity = #entity_ident;
|
|
|
+
|
|
|
+ fn unique() -> bool { false }
|
|
|
+ fn part_name() -> &'static str { "id" }
|
|
|
+
|
|
|
+ fn desc() -> Option<&'static str> { None }
|
|
|
+
|
|
|
+ fn get_datum(from: &Self::Entity) -> &Self::Datum {
|
|
|
+ unreachable!()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
impl ::std::fmt::Debug for #entity_ident {
|
|
|
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> {
|
|
|
use ::microrm::schema::datum::Datum;
|
|
@@ -277,6 +281,7 @@ pub fn derive(tokens: proc_macro::TokenStream) -> proc_macro::TokenStream {
|
|
|
type Parts = #parts_list;
|
|
|
type Keys = #key_list;
|
|
|
type ID = #id_ident;
|
|
|
+ type IDPart = #id_part_ident;
|
|
|
|
|
|
fn build(values: <Self::Parts as ::microrm::schema::entity::EntityPartList>::DatumList) -> Self {
|
|
|
Self {
|