@@ -83,8 +83,9 @@ impl TableDoc {
8383 name : String ,
8484 doc : Option < String > ,
8585 columns : Vec < ColumnDoc > ,
86+ file : Option < PathBuf > ,
8687 ) -> Self {
87- Self { schema, name, doc, columns }
88+ Self { schema, name, doc, columns, file }
8889 }
8990
9091 /// Getter for the `Schema` of the table (if there is one)
@@ -207,8 +208,15 @@ impl SqlFileDoc {
207208 name,
208209 Some ( comment. text ( ) . to_string ( ) ) ,
209210 column_docs,
211+ Some ( file. path_into_path_buf ( ) ) ,
212+ ) ,
213+ None => TableDoc :: new (
214+ schema,
215+ name,
216+ None ,
217+ column_docs,
218+ Some ( file. path_into_path_buf ( ) ) ,
210219 ) ,
211- None => TableDoc :: new ( schema, name, None , column_docs) ,
212220 } ;
213221 tables. push ( table_doc) ;
214222 }
@@ -301,6 +309,7 @@ mod tests {
301309 "user" . to_string ( ) ,
302310 Some ( "The table for users" . to_string ( ) ) ,
303311 columns,
312+ None ,
304313 ) ;
305314 let tables = vec ! [ table_doc] ;
306315 let sql_doc = SqlFileDoc :: new ( tables) ;
@@ -365,6 +374,7 @@ mod tests {
365374 ColumnDoc :: new( "email" . to_string( ) , None ) ,
366375 ColumnDoc :: new( "created_at" . to_string( ) , None ) ,
367376 ] ,
377+ None ,
368378 ) ,
369379 TableDoc :: new(
370380 None ,
@@ -377,6 +387,7 @@ mod tests {
377387 ColumnDoc :: new( "body" . to_string( ) , None ) ,
378388 ColumnDoc :: new( "published_at" . to_string( ) , None ) ,
379389 ] ,
390+ None ,
380391 ) ,
381392 ] )
382393 }
@@ -398,6 +409,7 @@ mod tests {
398409 Some ( "When the user registered" . to_string( ) ) ,
399410 ) ,
400411 ] ,
412+ None ,
401413 ) ,
402414 TableDoc :: new(
403415 None ,
@@ -416,6 +428,7 @@ mod tests {
416428 Some ( "When the post was created" . to_string( ) ) ,
417429 ) ,
418430 ] ,
431+ None ,
419432 ) ,
420433 ] ) ;
421434 docs. push ( first_docs) ;
@@ -440,6 +453,7 @@ mod tests {
440453 Some ( "When the user registered\n multiline" . to_string( ) ) ,
441454 ) ,
442455 ] ,
456+ None ,
443457 ) ,
444458 TableDoc :: new(
445459 None ,
@@ -461,6 +475,7 @@ mod tests {
461475 Some ( "When the post was created\n multiline" . to_string( ) ) ,
462476 ) ,
463477 ] ,
478+ None ,
464479 ) ,
465480 ] ) ;
466481 docs. push ( second_docs) ;
@@ -486,8 +501,10 @@ mod tests {
486501 "table" . to_string ( ) ,
487502 Some ( "table doc" . to_string ( ) ) ,
488503 vec ! [ col_doc] ,
504+ None ,
489505 ) ;
490- let table_doc_no_doc = TableDoc :: new ( None , "table" . to_string ( ) , None , vec ! [ col_doc_no_doc] ) ;
506+ let table_doc_no_doc =
507+ TableDoc :: new ( None , "table" . to_string ( ) , None , vec ! [ col_doc_no_doc] , None ) ;
491508 assert_eq ! ( table_doc. name( ) , "table" ) ;
492509 assert_eq ! ( table_doc. schema( ) , Some ( "schema" ) ) ;
493510 assert_eq ! (
@@ -600,6 +617,7 @@ mod tests {
600617 "users" . into ( ) ,
601618 Some ( "table doc" . into ( ) ) ,
602619 vec ! [ col_with_doc. clone( ) , col_without_doc] ,
620+ None ,
603621 ) ;
604622
605623 let col_writes = count_writes ( & col_with_doc) ;
@@ -634,7 +652,7 @@ mod tests {
634652
635653 #[ test]
636654 fn table_doc_set_doc_updates_doc ( ) {
637- let mut table = TableDoc :: new ( None , "users" . to_string ( ) , None , Vec :: new ( ) ) ;
655+ let mut table = TableDoc :: new ( None , "users" . to_string ( ) , None , Vec :: new ( ) , None ) ;
638656 assert_eq ! ( table. name( ) , "users" ) ;
639657 assert_eq ! ( table. schema( ) , None ) ;
640658 assert_eq ! ( table. doc( ) , None ) ;
@@ -654,6 +672,7 @@ mod tests {
654672 ColumnDoc :: new( "id" . to_string( ) , None ) ,
655673 ColumnDoc :: new( "username" . to_string( ) , None ) ,
656674 ] ,
675+ None ,
657676 ) ;
658677
659678 {
0 commit comments