@@ -125,7 +125,7 @@ pub async fn cmd_export(orm: OrmArg, export_dir: Option<PathBuf>) -> Result<()>
125125
126126 // Ensure mod chain for SeaORM (must be done after all files are written)
127127 if matches ! ( orm_kind, Orm :: SeaOrm ) {
128- for ( _ , rel_path) in & normalized_models {
128+ for ( _table , rel_path) in & normalized_models {
129129 let out_path = build_output_path ( & target_root, rel_path, orm_kind) ;
130130 ensure_mod_chain ( & target_root, rel_path)
131131 . await
@@ -342,8 +342,7 @@ async fn load_models_recursive(base: &Path) -> Result<Vec<(TableDef, PathBuf)>>
342342}
343343
344344async fn ensure_mod_chain ( root : & Path , rel_path : & Path ) -> Result < ( ) > {
345- // Only needed for SeaORM (Rust) exports to wire modules.
346- // Strip extension and ".vespertide" suffix from filename
345+ // SeaORM exports use a standard nested Rust module tree.
347346 let path_without_ext = rel_path. with_extension ( "" ) ;
348347 let path_stripped = if let Some ( stem) = path_without_ext. file_stem ( ) . and_then ( |s| s. to_str ( ) ) {
349348 let stripped_stem = stem. strip_suffix ( ".vespertide" ) . unwrap_or ( stem) ;
@@ -366,7 +365,7 @@ async fn ensure_mod_chain(root: &Path, rel_path: &Path) -> Result<()> {
366365 if comps. is_empty ( ) {
367366 return Ok ( ( ) ) ;
368367 }
369- // Build from deepest file up to root: dir/mod.rs should include child module.
368+
370369 while let Some ( child) = comps. pop ( ) {
371370 let dir = root. join ( comps. join ( std:: path:: MAIN_SEPARATOR_STR ) ) ;
372371 let mod_path = dir. join ( "mod.rs" ) ;
@@ -375,13 +374,15 @@ async fn ensure_mod_chain(root: &Path, rel_path: &Path) -> Result<()> {
375374 {
376375 fs:: create_dir_all ( parent) . await ?;
377376 }
377+
378378 let mut content = if mod_path. exists ( ) {
379379 fs:: read_to_string ( & mod_path) . await ?
380380 } else {
381381 String :: new ( )
382382 } ;
383- let decl = format ! ( "pub mod {};" , child) ;
384- if !content. lines ( ) . any ( |l| l. trim ( ) == decl) {
383+
384+ let decl = format ! ( "pub mod {child};" ) ;
385+ if !content. lines ( ) . any ( |line| line. trim ( ) == decl) {
385386 if !content. is_empty ( ) && !content. ends_with ( '\n' ) {
386387 content. push ( '\n' ) ;
387388 }
@@ -390,6 +391,7 @@ async fn ensure_mod_chain(root: &Path, rel_path: &Path) -> Result<()> {
390391 fs:: write ( mod_path, content) . await ?;
391392 }
392393 }
394+
393395 Ok ( ( ) )
394396}
395397
@@ -535,7 +537,7 @@ mod tests {
535537 let content = std_fs:: read_to_string ( out) . unwrap ( ) ;
536538 assert ! ( content. contains( "#[sea_orm(table_name = \" posts\" )]" ) ) ;
537539
538- // mod.rs wiring
540+ // nested mod.rs wiring
539541 let root_mod = custom. join ( "mod.rs" ) ;
540542 let blog_mod = custom. join ( "blog/mod.rs" ) ;
541543 assert ! ( root_mod. exists( ) ) ;
@@ -779,6 +781,7 @@ mod tests {
779781 let blog_mod = std_fs:: read_to_string ( root. join ( "blog/mod.rs" ) ) . unwrap ( ) ;
780782 assert ! ( root_mod. contains( "pub mod blog;" ) ) ;
781783 assert ! ( blog_mod. contains( "pub mod post;" ) ) ;
784+ assert ! ( !root_mod. contains( "post_vespertide" ) ) ;
782785 assert ! ( !blog_mod. contains( "post_vespertide" ) ) ;
783786 }
784787
0 commit comments