Skip to content

Commit 141c142

Browse files
committed
WIP: Completely redesigned FieldProxy
1 parent 1889a56 commit 141c142

File tree

22 files changed

+1146
-1014
lines changed

22 files changed

+1146
-1014
lines changed

rorm-macro-impl/src/generate/model.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ pub fn generate_model(model: &AnalyzedModel, config: &MacroConfig) -> TokenStrea
6565
impl #impl_generics #rorm_path::model::Model for #ident #type_generics #where_clause {
6666
type Primary = #primary_struct #type_generics;
6767

68-
type Fields<P: #rorm_path::internal::relation_path::Path> = #fields_struct_ident #type_generics_with_path;
68+
type Fields<P: 'static> = #fields_struct_ident #type_generics_with_path;
6969

7070
const TABLE: &'static str = #table;
7171
const SOURCE: #rorm_path::internal::hmr::Source = #source;
@@ -326,12 +326,13 @@ fn generate_fields_struct(model: &AnalyzedModel, config: &MacroConfig) -> (Ident
326326
});
327327
let fields_ident_1 = model.fields.iter().map(|field| &field.ident);
328328
let fields_ident_2 = fields_ident_1.clone();
329-
let fields_type = model.fields.iter().map(|field| &field.unit);
329+
let fields_type = model.fields.iter().map(|field| &field.ty);
330+
let fields_unit = model.fields.iter().map(|field| &field.unit);
330331

331332
let mut generics = model.experimental_generics.clone();
332-
generics.params.push(GenericParam::Type(
333-
syn::parse_quote!(Path: #rorm_path::internal::relation_path::Path),
334-
));
333+
generics
334+
.params
335+
.push(GenericParam::Type(syn::parse_quote!(Path: 'static)));
335336
let (impl_generics_with_path, type_generics_with_path, _) = generics.split_for_impl();
336337
let (_, type_generics, where_clause) = model.experimental_generics.split_for_impl();
337338

@@ -341,7 +342,11 @@ fn generate_fields_struct(model: &AnalyzedModel, config: &MacroConfig) -> (Ident
341342
#vis struct #ident #impl_generics_with_path #where_clause {
342343
#(
343344
#[doc = #fields_doc]
344-
#fields_vis #fields_ident_1: #rorm_path::fields::proxy::FieldProxy<(#fields_type #type_generics, Path)>,
345+
#fields_vis #fields_ident_1: #rorm_path::fields::proxy::FieldProxy<(
346+
#fields_unit #type_generics,
347+
Path,
348+
<#fields_type #type_generics as #rorm_path::fields::traits::FieldType>::FieldProxyLayers,
349+
)>,
345350
)*
346351
}
347352
impl #impl_generics_with_path #rorm_path::internal::ConstRef for #ident #type_generics_with_path #where_clause {

src/crud/insert.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::conditions::Value;
1010
use crate::crud::decoder::Decoder;
1111
use crate::crud::selector::Selector;
1212
use crate::fields::proxy;
13-
use crate::fields::proxy::FieldProxy;
13+
use crate::fields::proxy::{FieldProxy, LayerStackBase};
1414
use crate::fields::utils::column_name::ColumnName;
1515
use crate::internal::patch::{IntoPatchCow, PatchCow};
1616
use crate::internal::query_context::QueryContext;
@@ -148,7 +148,9 @@ where
148148
}
149149

150150
/// Return the tables primary key after performing the insert
151-
pub fn return_primary_key(self) -> InsertBuilder<E, M, FieldProxy<(M::Primary, M)>> {
151+
pub fn return_primary_key(
152+
self,
153+
) -> InsertBuilder<E, M, FieldProxy<(M::Primary, M, LayerStackBase)>> {
152154
self.set_return(proxy::new())
153155
}
154156

0 commit comments

Comments
 (0)