@@ -214,6 +214,33 @@ protected override ShapedQueryExpression TranslateElementAtOrDefault(
214214
215215 protected override ShapedQueryExpression TransformJsonQueryToTable ( JsonQueryExpression jsonQueryExpression )
216216 {
217+ // TODO: Implement JSON_TABLE support for structural types (entities/complex types) in JSON collections.
218+ //
219+ // Current Status:
220+ // - TransformJsonQueryToTable implementation is complete and matches Npgsql pattern
221+ // - JSON_TABLE syntax and COLUMNS clause generation is correct
222+ // - Issue is in EF Core base SelectExpression.AddCrossJoin or MySQL SQL generator
223+ // - When TranslateSelectMany calls AddCrossJoin, the CROSS JOIN keyword is not generated
224+ // - This results in invalid SQL: "FROM table1 JSON_TABLE(...)" instead of "FROM table1 CROSS JOIN JSON_TABLE(...)"
225+ //
226+ // Investigation completed:
227+ // - Npgsql uses identical CreateSelect pattern and it works for PostgreSQL
228+ // - MySQL supports both comma and CROSS JOIN syntax with JSON_TABLE (manually verified)
229+ // - The bug is in query assembly, not in provider-specific logic
230+ // - Requires either: override TranslateSelectMany, patch EF Core AddCrossJoin, or fix MySQL SQL generator
231+ //
232+ // Partial implementation preserved below for reference (currently commented out).
233+ // See commits: 11dc6b2, e17a1e9, 4b80703 for full implementation details.
234+
235+ // For now, throw a clear exception to inform users this is not yet supported
236+ throw new InvalidOperationException (
237+ "Composing LINQ operators (such as SelectMany) over collections of structural types inside JSON documents " +
238+ "is not currently supported by the MySQL provider. This feature requires fixes in EF Core's query assembly " +
239+ "logic or MySQL-specific SQL generation. As a workaround, consider materializing the JSON data to the client " +
240+ "using .AsEnumerable() or .ToList() before performing collection operations." ) ;
241+
242+ /* PARTIAL IMPLEMENTATION - PRESERVED FOR FUTURE WORK
243+
217244 // Calculate the table alias for the JSON_TABLE function based on the last named path segment
218245 // (or the JSON column name if there are none)
219246 var lastNamedPathSegment = jsonQueryExpression.Path.LastOrDefault(ps => ps.PropertyName is not null);
@@ -347,6 +374,7 @@ [new PathSegment(_sqlExpressionFactory.Constant("*", RelationalTypeMapping.NullM
347374 new ProjectionMember(),
348375 typeof(ValueBuffer)),
349376 false));
377+ */
350378 }
351379
352380 protected override ShapedQueryExpression TranslatePrimitiveCollection ( SqlExpression sqlExpression , IProperty property , string tableAlias )
0 commit comments