-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Fix HasJsonPropertyName for complex properties #37019
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Updated RelationalComplexPropertyExtensions to delegate Get/SetJsonPropertyName to ComplexType - Updated RelationalTypeBaseExtensions.GetJsonPropertyName to return null for root JSON types (those with ContainerColumnName) - Updated query pipeline files to call GetJsonPropertyName on complex property instead of complex type - Added assertion in ComplexCollection_can_have_nested_complex_properties_mapped_to_json test - Added HasJsonPropertyName test from PR #37018 Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
AndriySvyryd
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot Update Complex_types_mapped_to_json_are_stored_in_snapshot test
src/EFCore.Relational/Extensions/RelationalComplexPropertyExtensions.cs
Outdated
Show resolved
Hide resolved
src/EFCore.Relational/Extensions/RelationalComplexPropertyExtensions.cs
Outdated
Show resolved
Hide resolved
src/EFCore.Relational/Extensions/RelationalTypeBaseExtensions.cs
Outdated
Show resolved
Hide resolved
...l/Query/RelationalShapedQueryCompilingExpressionVisitor.ShaperProcessingExpressionVisitor.cs
Outdated
Show resolved
Hide resolved
src/EFCore.Sqlite.Core/Query/Internal/SqliteQueryableMethodTranslatingExpressionVisitor.cs
Outdated
Show resolved
Hide resolved
src/EFCore.SqlServer/Query/Internal/SqlServerQueryableMethodTranslatingExpressionVisitor.cs
Outdated
Show resolved
Hide resolved
- Reverted query pipeline changes (SelectExpression, JsonQueryExpression, ShaperProcessingExpressionVisitor, SqliteQueryable, SqlServerQueryable) - Removed casts in RelationalComplexPropertyExtensions by calling methods directly on ComplexType - Moved ContainerColumnName check earlier in GetJsonPropertyName and returned null if annotation value is null - Moved SetJsonPropertyName to IMutableTypeBase and IConventionTypeBase - Made EntityType and ComplexProperty SetJsonPropertyName methods delegate to TypeBase methods - Updated AnnotationCodeGenerator to read JsonPropertyName from complex type instead of complex property Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
src/EFCore.Relational/Extensions/RelationalEntityTypeExtensions.cs
Outdated
Show resolved
Hide resolved
src/EFCore.Relational/Extensions/RelationalTypeBaseExtensions.cs
Outdated
Show resolved
Hide resolved
src/EFCore.Relational/Extensions/RelationalTypeBaseExtensions.cs
Outdated
Show resolved
Hide resolved
- Moved JsonPropertyName logic from GenerateFluentApiCalls(IComplexProperty) to GenerateFluentApiCalls(IComplexType) - Fixed infinite recursion by upcasting to IConventionTypeBase/IMutableTypeBase in EntityType methods - Simplified null check in GetJsonPropertyName to check annotation != null - Combined ContainerColumnName check with IsMappedToJson check using OR operator Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
|
@copilot Update progress by creating a concise description for this PR |
Updated the PR description to be more concise. The new description focuses on the core fix (storing annotation on complex type instead of property) and summarizes the key changes made. |
Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
roji
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed offline, to me it's more logical to configure the JSON property name on the property - in my mind the JSON name isn't part of the object, but rather of the association pointing to it. I understand this isn't consistent with how owned entities currently work, but if anything I'd change it the other way instead (maybe I'm missing the larger picture though).
But this is all quite internal in any case, and we can re-discuss in the future.
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
I agree that semantically it would make more sense to be on the navigation/property, but I think we chose to store it on the type because it was easier to lookup. I don't think it matters too much one way or the other as long as we are consistent |
Fixes #37009
Fixes
HasJsonPropertyName()configuration on complex properties and complex collections within JSON columns by storing the annotation on the complex type instead of the complex property.Changes
SetJsonPropertyName()extension methods toIMutableTypeBaseandIConventionTypeBaseComplexPropertyandEntityTypeextension methods to delegate to the newTypeBasemethodsTypeBase.GetJsonPropertyName()to returnnullfor root JSON types (those withContainerColumnName)AnnotationCodeGeneratorto generateHasJsonPropertyName()calls from complex type annotationsOriginal prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.