@@ -1026,42 +1026,51 @@ protected override void CheckComposableSql(string sql)
10261026
10271027 protected override Expression VisitSelect ( SelectExpression selectExpression )
10281028 {
1029- Console . WriteLine ( $ "[DEBUG SQL] VisitSelect called - Tables: { selectExpression . Tables . Count } , Projection: { selectExpression . Projection . Count } ") ;
1030-
1031- // Log each projection item BEFORE calling base.VisitSelect
1032- for ( int i = 0 ; i < selectExpression . Projection . Count ; i ++ )
1029+ var logPath = "/tmp/mysql_debug.log" ;
1030+ try
10331031 {
1034- var projection = selectExpression . Projection [ i ] ;
1035- Console . WriteLine ( $ "[DEBUG SQL] Projection[{ i } ]: Alias='{ projection . Alias } ', Expression Type={ projection . Expression . GetType ( ) . Name } ") ;
1032+ System . IO . File . AppendAllText ( logPath , $ "\n [DEBUG SQL] VisitSelect called - Tables: { selectExpression . Tables . Count } , Projection: { selectExpression . Projection . Count } \n ") ;
10361033
1037- if ( projection . Expression is ColumnExpression col )
1034+ // Log each projection item BEFORE calling base.VisitSelect
1035+ for ( int i = 0 ; i < selectExpression . Projection . Count ; i ++ )
10381036 {
1039- Console . WriteLine ( $ "[DEBUG SQL] ColumnExpression: Name='{ col . Name } ', TypeMapping={ col . TypeMapping ? . GetType ( ) . Name ?? "null" } ") ;
1040- if ( col . TypeMapping != null )
1037+ var projection = selectExpression . Projection [ i ] ;
1038+ System . IO . File . AppendAllText ( logPath , $ "[DEBUG SQL] Projection[{ i } ]: Alias='{ projection . Alias } ', Expression Type={ projection . Expression . GetType ( ) . Name } \n ") ;
1039+
1040+ if ( projection . Expression is ColumnExpression col )
10411041 {
1042- Console . WriteLine ( $ "[DEBUG SQL] TypeMapping: ClrType={ col . TypeMapping . ClrType . Name } , StoreType='{ col . TypeMapping . StoreType } '") ;
1042+ System . IO . File . AppendAllText ( logPath , $ "[DEBUG SQL] ColumnExpression: Name='{ col . Name } ', TypeMapping={ col . TypeMapping ? . GetType ( ) . Name ?? "null" } \n ") ;
1043+ if ( col . TypeMapping != null )
1044+ {
1045+ System . IO . File . AppendAllText ( logPath , $ "[DEBUG SQL] TypeMapping: ClrType={ col . TypeMapping . ClrType . Name } , StoreType='{ col . TypeMapping . StoreType } '\n ") ;
1046+ }
1047+ }
1048+ else if ( projection . Expression is SqlConstantExpression constant )
1049+ {
1050+ System . IO . File . AppendAllText ( logPath , $ "[DEBUG SQL] SqlConstantExpression: Value={ constant . Value } , TypeMapping={ constant . TypeMapping ? . GetType ( ) . Name ?? "null" } \n ") ;
1051+ }
1052+ else
1053+ {
1054+ System . IO . File . AppendAllText ( logPath , $ "[DEBUG SQL] Other Expression: { projection . Expression } \n ") ;
10431055 }
1044- }
1045- else if ( projection . Expression is SqlConstantExpression constant )
1046- {
1047- Console . WriteLine ( $ "[DEBUG SQL] SqlConstantExpression: Value={ constant . Value } , TypeMapping={ constant . TypeMapping ? . GetType ( ) . Name ?? "null" } ") ;
1048- }
1049- else
1050- {
1051- Console . WriteLine ( $ "[DEBUG SQL] Other Expression: { projection . Expression } ") ;
10521056 }
10531057 }
1058+ catch { }
10541059
10551060 var result = base . VisitSelect ( selectExpression ) ;
10561061
1057- // Log current SQL state after SELECT is generated
1058- var currentSql = Sql . ToString ( ) ;
1059- var lastSelect = currentSql . LastIndexOf ( "SELECT" ) ;
1060- if ( lastSelect >= 0 )
1062+ try
10611063 {
1062- var sqlFragment = currentSql . Substring ( lastSelect , Math . Min ( 200 , currentSql . Length - lastSelect ) ) ;
1063- Console . WriteLine ( $ "[DEBUG SQL] After VisitSelect: { sqlFragment } ") ;
1064+ // Log current SQL state after SELECT is generated
1065+ var currentSql = Sql . ToString ( ) ;
1066+ var lastSelect = currentSql . LastIndexOf ( "SELECT" ) ;
1067+ if ( lastSelect >= 0 )
1068+ {
1069+ var sqlFragment = currentSql . Substring ( lastSelect , Math . Min ( 200 , currentSql . Length - lastSelect ) ) ;
1070+ System . IO . File . AppendAllText ( logPath , $ "[DEBUG SQL] After VisitSelect: { sqlFragment } \n ") ;
1071+ }
10641072 }
1073+ catch { }
10651074
10661075 return result ;
10671076 }
0 commit comments