Skip to content

Commit f8acf3e

Browse files
Copilotrenemadsen
andcommitted
Clean up: Remove debug logging from VisitSelect
Removed the temporary debug logging code now that the root cause has been identified and fixed. The logging served its purpose in diagnosing the JsonScalarExpression empty path issue. SUMMARY OF FIX: - Created MySqlStructuralJsonTypeMapping for complex JSON types (ClrType=JsonTypePlaceholder) - Fixed VisitJsonScalar() to generate SQL for empty paths (entire column projections) - Result: 48/54 ComplexJson tests now passing (was 0/54 before fix) - Original "No coercion operator is defined" error: RESOLVED ✅ Co-authored-by: renemadsen <76994+renemadsen@users.noreply.github.com>
1 parent 3d78514 commit f8acf3e

1 file changed

Lines changed: 1 addition & 74 deletions

File tree

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

Lines changed: 1 addition & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,80 +1029,7 @@ protected override void CheckComposableSql(string sql)
10291029

10301030
protected override Expression VisitSelect(SelectExpression selectExpression)
10311031
{
1032-
var logPath = "/tmp/mysql_debug.log";
1033-
try
1034-
{
1035-
System.IO.File.AppendAllText(logPath, $"\n[DEBUG SQL] VisitSelect called - Tables: {selectExpression.Tables.Count}, Projection: {selectExpression.Projection.Count}\n");
1036-
1037-
// Log each projection item BEFORE calling base.VisitSelect
1038-
for (int i = 0; i < selectExpression.Projection.Count; i++)
1039-
{
1040-
var projection = selectExpression.Projection[i];
1041-
System.IO.File.AppendAllText(logPath, $"[DEBUG SQL] Projection[{i}]: Alias='{projection.Alias}', Expression Type={projection.Expression.GetType().Name}\n");
1042-
1043-
if (projection.Expression is ColumnExpression col)
1044-
{
1045-
System.IO.File.AppendAllText(logPath, $"[DEBUG SQL] ColumnExpression: Name='{col.Name}', TypeMapping={col.TypeMapping?.GetType().Name ?? "null"}\n");
1046-
if (col.TypeMapping != null)
1047-
{
1048-
System.IO.File.AppendAllText(logPath, $"[DEBUG SQL] TypeMapping: ClrType={col.TypeMapping.ClrType.Name}, StoreType='{col.TypeMapping.StoreType}'\n");
1049-
}
1050-
}
1051-
else if (projection.Expression is SqlConstantExpression constant)
1052-
{
1053-
System.IO.File.AppendAllText(logPath, $"[DEBUG SQL] SqlConstantExpression: Value={constant.Value}, TypeMapping={constant.TypeMapping?.GetType().Name ?? "null"}\n");
1054-
}
1055-
else if (projection.Expression.GetType().Name == "JsonScalarExpression")
1056-
{
1057-
// Use reflection to get properties since JsonScalarExpression is internal
1058-
var jsonExprType = projection.Expression.GetType();
1059-
var jsonProp = jsonExprType.GetProperty("Json");
1060-
var pathProp = jsonExprType.GetProperty("Path");
1061-
var typeMappingProp = jsonExprType.GetProperty("TypeMapping");
1062-
1063-
var jsonVal = jsonProp?.GetValue(projection.Expression);
1064-
var pathVal = pathProp?.GetValue(projection.Expression);
1065-
var typeMappingVal = typeMappingProp?.GetValue(projection.Expression);
1066-
1067-
System.IO.File.AppendAllText(logPath, $"[DEBUG SQL] JsonScalarExpression: Json={jsonVal}, Path={pathVal}, TypeMapping={typeMappingVal?.GetType().Name ?? "null"}\n");
1068-
1069-
if (typeMappingVal != null)
1070-
{
1071-
var tmType = typeMappingVal.GetType();
1072-
var clrTypeProp = tmType.GetProperty("ClrType");
1073-
var storeTypeProp = tmType.GetProperty("StoreType");
1074-
var clrType = clrTypeProp?.GetValue(typeMappingVal) as Type;
1075-
var storeType = storeTypeProp?.GetValue(typeMappingVal) as string;
1076-
System.IO.File.AppendAllText(logPath, $"[DEBUG SQL] TypeMapping: ClrType={clrType?.Name ?? "null"}, StoreType='{storeType}'\n");
1077-
}
1078-
}
1079-
else
1080-
{
1081-
System.IO.File.AppendAllText(logPath, $"[DEBUG SQL] Other Expression: {projection.Expression}\n");
1082-
}
1083-
}
1084-
}
1085-
catch (Exception ex)
1086-
{
1087-
System.IO.File.AppendAllText(logPath, $"[DEBUG SQL] Error in logging: {ex.Message}\n");
1088-
}
1089-
1090-
var result = base.VisitSelect(selectExpression);
1091-
1092-
try
1093-
{
1094-
// Log current SQL state after SELECT is generated
1095-
var currentSql = Sql.ToString();
1096-
var lastSelect = currentSql.LastIndexOf("SELECT");
1097-
if (lastSelect >= 0)
1098-
{
1099-
var sqlFragment = currentSql.Substring(lastSelect, Math.Min(200, currentSql.Length - lastSelect));
1100-
System.IO.File.AppendAllText(logPath, $"[DEBUG SQL] After VisitSelect: {sqlFragment}\n");
1101-
}
1102-
}
1103-
catch { }
1104-
1105-
return result;
1032+
return base.VisitSelect(selectExpression);
11061033
}
11071034
}
11081035
}

0 commit comments

Comments
 (0)