@@ -3,7 +3,7 @@ use crate::ts_generator::sql_parser::quoted_strings::*;
33use color_eyre:: eyre:: Result ;
44use sqlparser:: ast:: { Assignment , AssignmentTarget , Expr , Join , SelectItem , TableFactor , TableWithJoins } ;
55
6- pub fn get_default_table ( table_with_joins : & Vec < TableWithJoins > ) -> String {
6+ pub fn get_default_table ( table_with_joins : & [ TableWithJoins ] ) -> String {
77 table_with_joins
88 . first ( )
99 . and_then ( |x| match & x. relation {
@@ -25,8 +25,8 @@ pub fn get_default_table(table_with_joins: &Vec<TableWithJoins>) -> String {
2525}
2626
2727pub fn find_table_name_from_identifier (
28- table_with_joins : & Vec < TableWithJoins > ,
29- identifiers : & Vec < String > , // can be the actual identifier or an alias
28+ table_with_joins : & [ TableWithJoins ] ,
29+ identifiers : & [ String ] , // can be the actual identifier or an alias
3030) -> Result < String , TsGeneratorError > {
3131 let left = identifiers
3232 . first ( )
@@ -128,11 +128,11 @@ pub fn translate_table_from_expr(
128128 Expr :: Identifier ( _) => Ok ( get_default_table ( table_with_joins) ) ,
129129 Expr :: CompoundIdentifier ( compound_identifier) => {
130130 // Assumes that [0] of the compound identifiers is the alias that points to the table
131- let identifiers = & compound_identifier
131+ let identifiers: Vec < String > = compound_identifier
132132 . iter ( )
133133 . map ( |x| DisplayIndent ( x) . to_string ( ) )
134134 . collect ( ) ;
135- find_table_name_from_identifier ( table_with_joins, identifiers)
135+ find_table_name_from_identifier ( table_with_joins, & identifiers)
136136 }
137137 _ => Err ( TsGeneratorError :: UnknownErrorWhileProcessingTableWithJoins (
138138 expr. to_string ( ) ,
@@ -141,7 +141,7 @@ pub fn translate_table_from_expr(
141141}
142142
143143pub fn translate_table_from_assignments (
144- table_with_joins : & Vec < TableWithJoins > ,
144+ table_with_joins : & [ TableWithJoins ] ,
145145 assignment : & Assignment ,
146146) -> Result < String , TsGeneratorError > {
147147 // In sqlparser 0.59.0, Assignment.id was replaced with Assignment.target
@@ -158,7 +158,7 @@ pub fn translate_table_from_assignments(
158158 match first_part {
159159 Some ( part) => {
160160 if let Some ( ident) = part. as_ident ( ) {
161- find_table_name_from_identifier ( table_with_joins, & vec ! [ ident. value. to_string( ) ] )
161+ find_table_name_from_identifier ( table_with_joins, & [ ident. value . to_string ( ) ] )
162162 } else {
163163 // If it's a function-based name, use default table
164164 Ok ( get_default_table ( table_with_joins) )
@@ -192,11 +192,11 @@ pub fn translate_table_with_joins(
192192 match expr {
193193 Expr :: CompoundIdentifier ( compound_identifier) => {
194194 // Assumes that [0] of the compound identifiers is the alias that points to the table
195- let identifiers = & compound_identifier
195+ let identifiers: Vec < String > = compound_identifier
196196 . iter ( )
197197 . map ( |x| DisplayIndent ( x) . to_string ( ) )
198198 . collect ( ) ;
199- find_table_name_from_identifier ( table_with_joins, identifiers)
199+ find_table_name_from_identifier ( table_with_joins, & identifiers)
200200 }
201201 _ => Ok ( default_table_name) ,
202202 }
@@ -208,11 +208,11 @@ pub fn translate_table_with_joins(
208208 Ok ( default_table_name)
209209 }
210210 Expr :: CompoundIdentifier ( compound_identifier) => {
211- let identifiers = & compound_identifier
211+ let identifiers: Vec < String > = compound_identifier
212212 . iter ( )
213213 . map ( |x| DisplayIndent ( x) . to_string ( ) )
214214 . collect ( ) ;
215- find_table_name_from_identifier ( table_with_joins, identifiers)
215+ find_table_name_from_identifier ( table_with_joins, & identifiers)
216216 }
217217 _ => Ok ( default_table_name) ,
218218 } ,
0 commit comments