Skip to content
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

type cast segments for derived types #149

Merged
merged 28 commits into from
Dec 16, 2021
Merged

type cast segments for derived types #149

merged 28 commits into from
Dec 16, 2021

Conversation

baywet
Copy link
Member

@baywet baywet commented Nov 24, 2021

fixes #124

Summary

This pull request adds two new settings EnableODataTypeCast (default true) and RequireDerivedTypesConstraintForODataTypeCastSegments (default true) and adds type cast segments for singletons, entity sets, entity set items (keys), navigation properties bound to a single item, navigation properties items (key) of types which have derived types.
It also adds child type operations and child type navigation properties under the singleton, entity set item, single nav prop, and nav prop item cast segments.
It also adds count segments under cast segment that are under collection navigation properties and entity sets.
With examples:

  • ~/singleton/ns.typecast + (derived type nav props, derived type operations)
  • ~/.../singlenavproperty/ns.type + (derived type nav props, derived type operations)
  • ~/.../multiplenavproperty/ns.type + (derived type collection operations, count)
  • ~/.../multiplenavproperty/{id}/ns.type + (derived type nav props, derived type operations)
  • ~/entityset/ns.type + (derived type collection operations, count)
  • ~/entityset/{id}/ns.type + (derived type nav props, derived type operations)

It will read the derived type constraints annotations for example

<Annotation Term="Org.OData.Validation.V1.DerivedTypeConstraint">
          <Collection>
            <String>microsoft.graph.user</String>
            <String>microsoft.graph.group</String>
            <String>microsoft.graph.application</String>
            <String>microsoft.graph.servicePrincipal</String>
            <String>microsoft.graph.device</String>
            <String>microsoft.graph.orgContact</String>
          </Collection>
        </Annotation>

The logic of whether the segments will be added or not can be exhaustively described with

Enable Require Annotation Found in annotation Result
true true true true Added
true true true false Noop
true true false true Impossible
true true false false Noop
true false true true Added
true false true false Noop
true false false true Impossible
true false false false Added
false true true true Noop
false true true false Noop
false true false true Noop
false true false false Noop
false false true true Noop
false false true false Noop
false false false true Noop
false false false false Noop

Or segments will only be added when the option is enabled and either:

  • annotation is required, present and contains the derived type name
  • annotation is not required, and (either annotation is present with the type name or absent)

@baywet baywet self-assigned this Nov 24, 2021
@baywet baywet added this to the 1.0.10 milestone Nov 24, 2021
@baywet baywet linked an issue Nov 24, 2021 that may be closed by this pull request
@darrelmiller

This comment has been minimized.

@baywet

This comment has been minimized.

@baywet baywet force-pushed the bugfix/odata-cast branch 2 times, most recently from 6ed38d2 to 03b4ff6 Compare December 7, 2021 19:29
@baywet baywet changed the base branch from bugfix/missing-quotes-templates to master December 7, 2021 19:29
@baywet baywet force-pushed the bugfix/odata-cast branch from 03b4ff6 to 4c86e26 Compare December 7, 2021 19:34
@baywet baywet marked this pull request as ready for review December 9, 2021 19:05
@baywet baywet changed the title bugfix/odata cast type cast segments for derived types Dec 9, 2021
@baywet baywet enabled auto-merge December 9, 2021 19:06
@baywet baywet requested a review from andrueastman December 9, 2021 19:10
@xuzhg
Copy link
Contributor

xuzhg commented Dec 9, 2021

Excuse me. But, Coding style, clean coding, making code readable... are my style. Thanks.

@baywet
Copy link
Member Author

baywet commented Dec 9, 2021

Excuse me. But, Coding style, clean coding, making code readable... are my style. Thanks.

The "Excuse me" part of this passive aggressive comment does not make it more acceptable. IDEs and people are going to have different configurations and preferences. If you care about tab, spaces, curlies and other details like that, please take the time to push a configuration that's enforced through tooling as described in #142 as as we've discussed offline.
Until some systematic linting is in place, arguing about those things and manually fixing those is a waste of time.

Now, can we focus on reviewing the code rather than the whites-pacing around the code please?

@baywet baywet requested a review from xuzhg December 9, 2021 20:12
@xuzhg
Copy link
Contributor

xuzhg commented Dec 15, 2021

:shipit:

Signed-off-by: Vincent Biret <[email protected]>
Signed-off-by: Vincent Biret <[email protected]>
- adds support for query parameters when in navigation properties

Signed-off-by: Vincent Biret <[email protected]>
baywet and others added 22 commits December 16, 2021 07:46
- fixes a bug where cast would be missing for non contained properties after the key

Signed-off-by: Vincent Biret <[email protected]>
… cast segments under collection segments

Signed-off-by: Vincent Biret <[email protected]>
Signed-off-by: Vincent Biret <[email protected]>
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.

Missing OData cast path items
3 participants