@@ -139,30 +139,6 @@ impl SqlDoc {
139139 }
140140 }
141141
142- /// Method for finding a specific [`TableDoc`] from `schema` and table `name`
143- ///
144- /// # Parameters
145- /// - the table's `schema` as a [`str`]
146- /// - the table's `name` as a [`str`]
147- ///
148- /// # Errors
149- /// - Will return [`DocError::TableNotFound`] if the expected table is not found
150- /// - Will return [`DocError::DuplicateTablesFound`] if more than one table is found
151- pub fn table_with_schema ( & self , schema : & str , name : & str ) -> Result < & TableDoc , DocError > {
152- let matches = self
153- . tables
154- . iter ( )
155- . filter ( |table_doc| table_doc. name ( ) == name && table_doc. schema ( ) == Some ( schema) )
156- . collect :: < Vec < & TableDoc > > ( ) ;
157- match matches. as_slice ( ) {
158- [ ] => Err ( DocError :: TableNotFound { name : name. to_owned ( ) } ) ,
159- [ only] => Ok ( * only) ,
160- _ => Err ( DocError :: DuplicateTablesFound {
161- tables : matches. into_iter ( ) . cloned ( ) . collect ( ) ,
162- } ) ,
163- }
164- }
165-
166142 /// Getter method for returning the `&[TableDoc]`
167143 #[ must_use]
168144 pub fn tables ( & self ) -> & [ TableDoc ] {
@@ -406,8 +382,8 @@ mod tests {
406382 let schema = "analytics" ;
407383 let schema_table = "events" ;
408384 assert_eq ! (
409- sql_doc. table_with_schema ( schema , schema_table ) ?,
410- expected_doc. table_with_schema ( schema , schema_table ) ?
385+ sql_doc. table ( schema_table , Some ( schema ) ) ?,
386+ expected_doc. table ( schema_table , Some ( schema ) ) ?
411387 ) ;
412388 let _ = fs:: remove_dir_all ( & base) ;
413389 Ok ( ( ) )
@@ -427,7 +403,7 @@ mod tests {
427403 #[ test]
428404 fn test_schema_err ( ) {
429405 let empty_set = SqlDoc :: new ( vec ! [ ] ) ;
430- let empty_table_err = empty_set. table_with_schema ( "schema ", "name" ) ;
406+ let empty_table_err = empty_set. table ( "name ", Some ( "schema" ) ) ;
431407 assert ! ( empty_table_err. is_err( ) ) ;
432408 assert ! ( matches!(
433409 empty_table_err,
@@ -437,7 +413,7 @@ mod tests {
437413 TableDoc :: new( Some ( "schema" . to_owned( ) ) , "duplicate" . to_owned( ) , None , vec![ ] , None ) ,
438414 TableDoc :: new( Some ( "schema" . to_owned( ) ) , "duplicate" . to_owned( ) , None , vec![ ] , None ) ,
439415 ] ) ;
440- let duplicate_tables_err = duplicate_set. table_with_schema ( "schema ", "duplicate" ) ;
416+ let duplicate_tables_err = duplicate_set. table ( "duplicate ", Some ( "schema" ) ) ;
441417 assert ! ( matches!( duplicate_tables_err, Err ( DocError :: DuplicateTablesFound { .. } ) ) ) ;
442418 }
443419
0 commit comments