11use crate :: common:: lazy:: DB_SCHEMA ;
22use crate :: ts_generator:: errors:: TsGeneratorError ;
3+ use crate :: ts_generator:: sql_parser:: expressions:: function_handlers:: FunctionHandlersContext ;
34use crate :: ts_generator:: sql_parser:: expressions:: translate_data_type:: translate_value;
45use crate :: ts_generator:: sql_parser:: expressions:: translate_table_with_joins:: translate_table_from_expr;
56use crate :: ts_generator:: sql_parser:: quoted_strings:: DisplayIndent ;
67use crate :: ts_generator:: types:: ts_query:: TsFieldType ;
7- use crate :: ts_generator:: sql_parser:: expressions:: function_handlers:: FunctionHandlersContext ;
88use sqlparser:: ast:: { Expr , Function , FunctionArg , FunctionArgExpr , FunctionArguments } ;
99
1010pub async fn handle_polymorphic_functions (
@@ -36,7 +36,11 @@ pub async fn handle_polymorphic_functions(
3636 Expr :: Identifier ( ident) => {
3737 let column_name = DisplayIndent ( ident) . to_string ( ) ;
3838 if let Some ( table_name) = ctx. single_table_name {
39- let table_details = & DB_SCHEMA . lock ( ) . await . fetch_table ( & vec ! [ table_name] , ctx. db_conn ) . await ;
39+ let table_details = & DB_SCHEMA
40+ . lock ( )
41+ . await
42+ . fetch_table ( & vec ! [ table_name] , ctx. db_conn )
43+ . await ;
4044
4145 if let Some ( table_details) = table_details {
4246 if let Some ( field) = table_details. get ( & column_name) {
@@ -76,7 +80,9 @@ pub async fn handle_polymorphic_functions(
7680 Expr :: Value ( val) => {
7781 // If first arg is a literal value, infer from that
7882 if let Some ( ts_field_type) = translate_value ( & val. value ) {
79- return ctx. ts_query . insert_result ( Some ( ctx. alias ) , & [ ts_field_type] , ctx. is_selection , false , expr_log) ;
83+ return ctx
84+ . ts_query
85+ . insert_result ( Some ( ctx. alias ) , & [ ts_field_type] , ctx. is_selection , false , expr_log) ;
8086 }
8187 }
8288 _ => { }
@@ -85,5 +91,7 @@ pub async fn handle_polymorphic_functions(
8591 }
8692
8793 // Fallback to Any if we couldn't infer the type
88- ctx. ts_query . insert_result ( Some ( ctx. alias ) , & [ TsFieldType :: Any ] , ctx. is_selection , false , expr_log)
94+ ctx
95+ . ts_query
96+ . insert_result ( Some ( ctx. alias ) , & [ TsFieldType :: Any ] , ctx. is_selection , false , expr_log)
8997}
0 commit comments