Skip to content

Commit 1845669

Browse files
Copilotrenemadsen
andcommitted
Debug: Enhanced projection logging in VisitSelect
Added detailed logging for each projection item in selectExpression.Projection: - Shows projection index, alias, and expression type - For ColumnExpression: logs column name, TypeMapping type, ClrType, and StoreType - For SqlConstantExpression: logs value and TypeMapping - For other expressions: logs the expression itself This will help identify why JSON columns with JsonTypePlaceholder TypeMapping are generating empty SQL fragments (`, ,`) instead of proper column names. The output should reveal whether TypeMapping properties are null or have unexpected values that prevent SQL generation. Co-authored-by: renemadsen <76994+renemadsen@users.noreply.github.com>
1 parent 7d2dae1 commit 1845669

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

src/EFCore.MySql/Query/ExpressionVisitors/Internal/MySqlQuerySqlGenerator.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,6 +1027,31 @@ protected override void CheckComposableSql(string sql)
10271027
protected override Expression VisitSelect(SelectExpression selectExpression)
10281028
{
10291029
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++)
1033+
{
1034+
var projection = selectExpression.Projection[i];
1035+
Console.WriteLine($"[DEBUG SQL] Projection[{i}]: Alias='{projection.Alias}', Expression Type={projection.Expression.GetType().Name}");
1036+
1037+
if (projection.Expression is ColumnExpression col)
1038+
{
1039+
Console.WriteLine($"[DEBUG SQL] ColumnExpression: Name='{col.Name}', TypeMapping={col.TypeMapping?.GetType().Name ?? "null"}");
1040+
if (col.TypeMapping != null)
1041+
{
1042+
Console.WriteLine($"[DEBUG SQL] TypeMapping: ClrType={col.TypeMapping.ClrType.Name}, StoreType='{col.TypeMapping.StoreType}'");
1043+
}
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}");
1052+
}
1053+
}
1054+
10301055
var result = base.VisitSelect(selectExpression);
10311056

10321057
// Log current SQL state after SELECT is generated

0 commit comments

Comments
 (0)