@@ -208,7 +208,7 @@ impl EntityWriter {
208
208
let with_prelude = context. with_prelude != WithPrelude :: None ;
209
209
files. push ( self . write_index_file ( context. lib , with_prelude, context. seaography ) ) ;
210
210
if with_prelude {
211
- files. push ( self . write_prelude ( context. with_prelude ) ) ;
211
+ files. push ( self . write_prelude ( context. with_prelude , context . frontend_format ) ) ;
212
212
}
213
213
if !self . enums . is_empty ( ) {
214
214
files. push ( self . write_sea_orm_active_enums (
@@ -337,13 +337,19 @@ impl EntityWriter {
337
337
}
338
338
}
339
339
340
- pub fn write_prelude ( & self , with_prelude : WithPrelude ) -> OutputFile {
340
+ pub fn write_prelude ( & self , with_prelude : WithPrelude , frontend_format : bool ) -> OutputFile {
341
341
let mut lines = Vec :: new ( ) ;
342
342
Self :: write_doc_comment ( & mut lines) ;
343
343
if with_prelude == WithPrelude :: AllAllowUnusedImports {
344
344
Self :: write_allow_unused_imports ( & mut lines)
345
345
}
346
- let code_blocks = self . entities . iter ( ) . map ( Self :: gen_prelude_use) . collect ( ) ;
346
+ let code_blocks = self . entities . iter ( ) . map ( {
347
+ if frontend_format {
348
+ Self :: gen_prelude_use
349
+ } else {
350
+ Self :: gen_prelude_use_model
351
+ }
352
+ } ) . collect ( ) ;
347
353
Self :: write ( & mut lines, code_blocks) ;
348
354
OutputFile {
349
355
name : "prelude.rs" . to_owned ( ) ,
@@ -860,6 +866,14 @@ impl EntityWriter {
860
866
}
861
867
}
862
868
869
+ pub fn gen_prelude_use_model ( entity : & Entity ) -> TokenStream {
870
+ let table_name_snake_case_ident = entity. get_table_name_snake_case_ident ( ) ;
871
+ let table_name_camel_case_ident = entity. get_table_name_camel_case_ident ( ) ;
872
+ quote ! {
873
+ pub use super :: #table_name_snake_case_ident:: Model as #table_name_camel_case_ident;
874
+ }
875
+ }
876
+
863
877
#[ allow( clippy:: too_many_arguments) ]
864
878
pub fn gen_compact_model_struct (
865
879
entity : & Entity ,
0 commit comments