Skip to content

Commit b80f676

Browse files
committed
Remove BelongsToMacro builder as the current design breaks belongs_to
1 parent e3df32d commit b80f676

File tree

2 files changed

+1
-22
lines changed

2 files changed

+1
-22
lines changed

postgres_resource_derive/src/builder.rs

+1-20
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
use crate::{r#struct::*, IdentExt};
22

33
use proc_macro2::Span;
4-
use syn::{Ident, parse::Result, LitStr};
5-
use heck::CamelCase;
4+
use syn::{parse::Result, LitStr};
65

76
pub struct Input {
87
pub parsed_struct: Struct,
@@ -62,21 +61,3 @@ impl<'i> Builder<'i> for DatabaseConnection {
6261
}
6362
}
6463
}
65-
66-
pub struct BelongsToMacro;
67-
68-
impl<'i> Builder<'i> for BelongsToMacro {
69-
fn build(self, input: &'i Input) -> Result<proc_macro2::TokenStream> {
70-
let mut macros = Vec::new();
71-
input.parsed_struct.fields
72-
.iter()
73-
.filter(|field| field.fk())
74-
.for_each(|field| {
75-
let mut name = field.name.to_string();
76-
name.truncate(name.len() - 2);
77-
let model_name = Ident::new(&name.to_camel_case(), Span::call_site());
78-
macros.push(quote!(#[belongs_to(#model_name)]));
79-
});
80-
Ok(quote!(#(#macros)*))
81-
}
82-
}

postgres_resource_derive/src/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,12 @@ impl Input {
5151

5252
fn gen_model(&self) -> Result<proc_macro2::TokenStream> {
5353
let table_macro = TableMacro.build(&self)?;
54-
let belongs_to = BelongsToMacro.build(&self)?;
5554

5655
let model_with_id = ModelWithId.build(&self)?;
5756
let model = Model.build(&self)?;
5857

5958
Ok(quote! {
6059
#[derive(Serialize, Deserialize, FromSqlRow, Associations, Identifiable, Debug, PartialEq)]
61-
#belongs_to
6260
#table_macro
6361
#model_with_id
6462

0 commit comments

Comments
 (0)