-
Notifications
You must be signed in to change notification settings - Fork 352
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
Issue2467: Support Core.AlternateKeys #2470
Conversation
a84ea21
to
07e1196
Compare
src/Microsoft.OData.Edm/Vocabularies/CoreVocabularyConstants.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Clément Habinshuti <clhabins@microsoft.com>
Co-authored-by: Clément Habinshuti <clhabins@microsoft.com>
This PR has Quantification details
Why proper sizing of changes matters
Optimal pull request sizes drive a better predictable PR flow as they strike a
What can I do to optimize my changes
How to interpret the change counts in git diff output
Was this comment helpful? 👍 :ok_hand: :thumbsdown: (Email) |
@habbes Thanks for your review and suggestions. |
@@ -2146,14 +2146,22 @@ public static bool IsKey(this IEdmProperty property) | |||
/// <param name="model">The model to be used.</param> | |||
/// <param name="type">Reference to the calling object.</param> | |||
/// <param name="alternateKey">Dictionary of alias and structural properties for the alternate key.</param> | |||
public static void AddAlternateKeyAnnotation(this EdmModel model, IEdmEntityType type, IDictionary<string, IEdmProperty> alternateKey) | |||
/// <param name="useCore">A flag to indicate which alternate term to use. | |||
/// If ture, 'Org.OData.Core.V1.AlternateKeys' is used, otherwise, 'OData.Community.Keys.V1.AlternateKeys' is used. |
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.
typo
{ | ||
EdmUtil.CheckArgumentNull(model, "model"); | ||
EdmUtil.CheckArgumentNull(type, "type"); | ||
EdmUtil.CheckArgumentNull(alternateKey, "alternateKey"); | ||
|
||
IEdmTerm alternateKeysTerm = useCore ? CoreVocabularyModel.AlternateKeysTerm : AlternateKeysVocabularyModel.AlternateKeysTerm; | ||
|
||
IEdmComplexType propertyRefType = useCore ? CoreVocabularyModel.PropertyRefType : AlternateKeysVocabularyModel.PropertyRefType; |
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.
UT and handling of duplicate entries under each annotation namespace?
|
||
// For backwards-compability, we merge the alternate keys from community and core vocabulary annotations. | ||
|
||
retrieveAnnotationAction(annotationValue); |
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.
The output of GetAlternateKeysAnnotation(this IEdmModel model, IEdmEntityType type)
does not honor the unicity requirements from the community vocabulary spec:
Services SHOULD NOT return multiple alternate key definitions for the same entity type that are composed of the exact same set of properties.
The alternate keys are not "merged" as the comment line 3483 calls out, it's instead an union that occurs.
Debug.Assert(keys != null, "expected IEdmCollectionExpression for alternate key annotation value"); | ||
|
||
foreach (IEdmRecordExpression key in keys.Elements.OfType<IEdmRecordExpression>()) | ||
Action<IEdmVocabularyAnnotation> retrieveAnnotationAction = ann => |
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.
Define a private static function rather than this action closure which will incur an extra allocation for each call.
Issues
This pull request fixes #2467.
Description
Checklist (Uncheck if it is not completed)
Additional work necessary
If documentation update is needed, please add "Docs Needed" label to the issue and provide details about the required document change in the issue.