@@ -20,7 +20,10 @@ pub fn generate_crud_from_parsed(
2020 let repo_name = format ! ( "{}Repository" , entity. struct_name) ;
2121 let repo_ident = format_ident ! ( "{}" , repo_name) ;
2222
23- let table_name = & entity. table_name ;
23+ let table_name = match & entity. schema_name {
24+ Some ( schema) => format ! ( "{}.{}" , schema, entity. table_name) ,
25+ None => entity. table_name . clone ( ) ,
26+ } ;
2427
2528 // Pool type (used via full path sqlx::PgPool etc., no import needed)
2629 let pool_type = pool_type_tokens ( db_kind) ;
@@ -29,7 +32,7 @@ pub fn generate_crud_from_parsed(
2932 // query_as! macro can't resolve the column type at compile time. Fall back to runtime query_as::<_, T>()
3033 // for queries that return rows. DELETE (no rows returned) can still use macro.
3134 let has_custom_sql_type = entity. fields . iter ( ) . any ( |f| f. sql_type . is_some ( ) ) ;
32- let use_macro = query_macro && !has_custom_sql_type;
35+ let use_macro = query_macro && !has_custom_sql_type && !entity . is_view ;
3336
3437 // Entity import
3538 imports. insert ( format ! ( "use {}::{};" , entity_module_path, entity. struct_name) ) ;
@@ -182,7 +185,7 @@ pub fn generate_crud_from_parsed(
182185 . map ( |f| {
183186 let name = format_ident ! ( "{}" , f. rust_name) ;
184187 let ty: TokenStream = f. inner_type . parse ( ) . unwrap ( ) ;
185- quote ! { #name: & #ty }
188+ quote ! { #name: #ty }
186189 } )
187190 . collect ( ) ;
188191
@@ -278,7 +281,7 @@ pub fn generate_crud_from_parsed(
278281 & sql_macro,
279282 & binds,
280283 db_kind,
281- table_name,
284+ & table_name,
282285 & pk_fields,
283286 & non_pk_fields,
284287 use_macro,
@@ -456,7 +459,7 @@ pub fn generate_crud_from_parsed(
456459 . map ( |f| {
457460 let name = format_ident ! ( "{}" , f. rust_name) ;
458461 let ty: TokenStream = f. inner_type . parse ( ) . unwrap ( ) ;
459- quote ! { #name: & #ty }
462+ quote ! { #name: #ty }
460463 } )
461464 . collect ( ) ;
462465
0 commit comments