Skip to content

Commit c9d31cb

Browse files
Copilotrenemadsen
andcommitted
Fix: Use DbType.String instead of null to enable SQL column projection
Changed MySqlStructuralJsonTypeMapping constructor to pass `System.Data.DbType.String` instead of `dbType: null` to match SQL Server's SqlServerStructuralJsonTypeMapping. ROOT CAUSE: The empty column projections (`, ,`) were caused by passing `dbType: null`. EF Core's SQL generator needs the DbType to determine how to project columns in SELECT statements. Without it, the generator cannot map JsonTypePlaceholder to actual column names, resulting in empty SQL fragments. SQL Server uses `DbType.String` with storeType="nvarchar(max)" or "json". PostgreSQL likely does the same (needs verification). This should resolve the SQL syntax errors while maintaining the string→MemoryStream conversion for data reading. Co-authored-by: renemadsen <76994+renemadsen@users.noreply.github.com>
1 parent 4448ed5 commit c9d31cb

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/EFCore.MySql/Storage/Internal/MySqlStructuralJsonTypeMapping.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ private static readonly ConstructorInfo _memoryStreamConstructor
3434
public static MySqlStructuralJsonTypeMapping Default { get; } = new("json");
3535

3636
public MySqlStructuralJsonTypeMapping(string storeType)
37-
: base(storeType, typeof(JsonTypePlaceholder), dbType: null)
37+
: base(storeType, typeof(JsonTypePlaceholder), System.Data.DbType.String)
3838
{
39-
Console.WriteLine($"[DEBUG] MySqlStructuralJsonTypeMapping created - StoreType: {storeType}, ClrType: JsonTypePlaceholder");
39+
Console.WriteLine($"[DEBUG] MySqlStructuralJsonTypeMapping created - StoreType: {storeType}, ClrType: JsonTypePlaceholder, DbType: String");
4040
}
4141

4242
protected MySqlStructuralJsonTypeMapping(RelationalTypeMappingParameters parameters)

0 commit comments

Comments
 (0)