Skip to content

Conversation

roji
Copy link
Member

@roji roji commented Jul 21, 2025

Review last commit only (the first two are boring cleanup/reorganization).

Part of #36296

@roji roji marked this pull request as ready for review July 21, 2025 11:33
@roji roji requested a review from a team as a code owner July 21, 2025 11:33
@roji roji mentioned this pull request Jul 19, 2025
16 tasks
@roji roji linked an issue Jul 21, 2025 that may be closed by this pull request
16 tasks
@@ -7,99 +7,4 @@ public class ComplexJsonSqlServerFixture : ComplexJsonRelationalFixtureBase
{
protected override ITestStoreFactory TestStoreFactory
=> SqlServerTestStoreFactory.Instance;

protected override async Task SeedAsync(PoolableDbContext context)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AndriySvyryd update pipeline is working perfectly - thanks!

/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
[EntityFrameworkInternal]
public static string? SerializeComplexTypeToJson(IComplexType complexType, object? value, bool isCollection)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AndriySvyryd note this code, which serializes a complex town to JSON, similar to what we already have in ModificationCommand for the update pipeline. Here we get the object itself (as specified inline in the query, or as a parameter), whereas in the update pipeline we of course deal with entries - so we probably can't deduplicate.

@@ -105,7 +105,7 @@ protected virtual string EscapeSqlLiteral(string literal)
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
protected override string GenerateNonNullSqlLiteral(object value)
=> $"'{EscapeSqlLiteral(JsonSerializer.Serialize(value))}'";
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note this pretty problematic code we had here - we can't use the high-level JsonSerializer ever since we have our own model of the type (shadow properties, ignored CLR properties...). I don't think this was actually getting used.

As usual, there's quite a lot of confusion in the query pipeline around scalars and structural JSON values... The type mapping should be a pure representation of the database type here (so nvarchar(max), json) and not of the CLR/structural type, so we should never be receiving an arbitrary .NET object here, only a string.

Going even further, I'm still not sure why we need a separate type mapping for owned/structural JSON as opposed to just JSON - I think it's because we use the type mapping to know whether we're dealing with a structural type or not. That's again conflating client-side and server-side (what's being read from the column is the domain of the shaper, and should not be in the type mapping).

@roji
Copy link
Member Author

roji commented Jul 21, 2025

Thanks for the quick review @cincuranet. I'll go ahead and merge once it's green, but @AndriySvyryd would also appreciate a review from you (product changes aren't huge here actually, and very localized) - can always integrate comments into a later PR.

@roji roji enabled auto-merge (rebase) July 21, 2025 11:50
@roji roji force-pushed the ComplexJsonEquality branch from 6aa9f27 to 59f98b1 Compare July 21, 2025 12:30
@roji roji merged commit 5d93d51 into dotnet:main Jul 21, 2025
7 checks passed
@roji roji deleted the ComplexJsonEquality branch July 21, 2025 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Complex JSON query support
2 participants