1- use std:: collections:: HashMap ;
2- use std:: path:: Path ;
3- use sqlmo:: { Constraint , Schema , Table } ;
1+ use crate :: config:: Config ;
2+ use anyhow:: Result as AnyResult ;
43use ormlite_attr:: { schema_from_filepaths, Ident , InnerType , Type } ;
54use ormlite_core:: schema:: FromMeta ;
6- use anyhow:: Result as AnyResult ;
7- use crate :: config:: Config ;
5+ use sqlmo:: { Constraint , Schema , Table } ;
6+ use std:: collections:: HashMap ;
7+ use std:: path:: Path ;
88
99pub fn schema_from_ormlite_project ( paths : & [ & Path ] , c : & Config ) -> AnyResult < Schema > {
1010 let mut schema = Schema :: default ( ) ;
@@ -29,7 +29,7 @@ pub fn schema_from_ormlite_project(paths: &[&Path], c: &Config) -> AnyResult<Sch
2929 let model_name = c. ty . inner_type_name ( ) ;
3030 let pkey = primary_key_type
3131 . get ( & model_name)
32- . expect ( & format ! ( "Could not find model {} for join" , model_name) ) ;
32+ . unwrap_or_else ( || panic ! ( "Could not find model {} for join" , model_name) ) ;
3333 c. ty = Type :: Inner ( pkey. clone ( ) ) ;
3434 }
3535 }
@@ -38,8 +38,11 @@ pub fn schema_from_ormlite_project(paths: &[&Path], c: &Config) -> AnyResult<Sch
3838 let table = Table :: from_meta ( & table) ;
3939 schema. tables . push ( table) ;
4040 }
41- let mut table_names: HashMap < String , ( String , String ) > =
42- schema. tables . iter ( ) . map ( |t| ( t. name . clone ( ) , ( t. name . clone ( ) , t. primary_key ( ) . unwrap ( ) . name . clone ( ) ) ) ) . collect ( ) ;
41+ let mut table_names: HashMap < String , ( String , String ) > = schema
42+ . tables
43+ . iter ( )
44+ . map ( |t| ( t. name . clone ( ) , ( t. name . clone ( ) , t. primary_key ( ) . unwrap ( ) . name . clone ( ) ) ) )
45+ . collect ( ) ;
4346 for ( alias, real) in & c. table . aliases {
4447 let Some ( real) = table_names. get ( real) else {
4548 continue ;
@@ -63,4 +66,5 @@ pub fn schema_from_ormlite_project(paths: &[&Path], c: &Config) -> AnyResult<Sch
6366 }
6467 }
6568 Ok ( schema)
66- }
69+ }
70+
0 commit comments