@@ -21,7 +21,7 @@ enum ColumnConstraint {
2121
2222fn statement_mermaid (
2323 statement : Statement ,
24- table_column_type : & mut HashMap < String , HashMap < String , DataType > > ,
24+ table_column_type : & mut HashMap < String , Vec < ( String , DataType ) > > ,
2525 table_colum_constraints : & mut HashMap < String , HashMap < String , HashSet < ColumnConstraint > > > ,
2626 column_foreign_key_column : & mut Vec < ( TableColumn , TableColumn , String ) > ,
2727) -> String {
@@ -47,22 +47,11 @@ fn statement_mermaid(
4747 like,
4848 } => {
4949 let mut column_constraints: HashMap < String , HashSet < ColumnConstraint > > = HashMap :: new ( ) ;
50- let mut column_type: HashMap < String , DataType > = HashMap :: new ( ) ;
50+ let mut column_type: Vec < ( String , DataType ) > = Vec :: new ( ) ;
5151 mermaid. push_str ( & format ! ( "\t {} {{\n " , name. to_string( ) . replace( '"' , "" ) ) ) ;
5252
5353 for column in columns {
54- column_type. insert ( column. name . to_string ( ) , column. data_type ) ;
55- // mermaid.push_str(&format!(
56- // "\t\t{} {}\n",
57- // column
58- // .data_type
59- // .to_string()
60- // .replace(' ', "_")
61- // .replace('(', "")
62- // .replace(')', "")
63- // .replace(',', "_"),
64- // column.name.to_string().replace('"', ""),
65- // ));
54+ column_type. push ( ( column. name . to_string ( ) , column. data_type ) ) ;
6655 for ColumnOptionDef {
6756 name : option_name,
6857 option,
@@ -219,7 +208,7 @@ pub fn sql_s_mermaid(sql: &str) -> String {
219208 let mut table_column_constraints: HashMap < String , HashMap < String , HashSet < ColumnConstraint > > > =
220209 HashMap :: new ( ) ;
221210 let mut column_foreign_key_column: Vec < ( TableColumn , TableColumn , String ) > = Vec :: new ( ) ;
222- let mut table_column_type: HashMap < String , HashMap < String , DataType > > = HashMap :: new ( ) ;
211+ let mut table_column_type: HashMap < String , Vec < ( String , DataType ) > > = HashMap :: new ( ) ;
223212
224213 let mut mermaid: String = "erDiagram\n " . to_string ( ) ;
225214
@@ -271,10 +260,10 @@ pub fn sql_s_mermaid(sql: &str) -> String {
271260 // draw links
272261 for ( ( l_table, l_column) , ( r_table, r_column) , foreign_key) in column_foreign_key_column {
273262 mermaid. push_str ( & format ! (
274- "\t {} }}o --{}{} {} : \" {}\" \n " ,
263+ "\t {} {}{} --{}{} {} : \" {}\" \n " ,
275264 l_table,
276- // one_or_many_relation(Side::Left, &l_table, &l_column, &table_column_constraints,),
277- // zero_or_one_relation(&l_table, &l_column, &table_column_constraints,),
265+ one_or_many_relation( Side :: Left , & l_table, & l_column, & table_column_constraints, ) ,
266+ "o" . to_string ( ) , // zero_or_one_relation(&l_table, &l_column, &table_column_constraints,),
278267 zero_or_one_relation( & r_table, & r_column, & table_column_constraints, ) ,
279268 one_or_many_relation( Side :: Right , & r_table, & r_column, & table_column_constraints, ) ,
280269 r_table,
0 commit comments