Uploaded image for project: 'OASIS Open Data Protocol (OData) TC'
  1. OASIS Open Data Protocol (OData) TC
  2. ODATA-365

Rename edm:AssertType to edm:Cast and clarify behavior of edm:Cast and cast()

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: V4.0_CSD01
    • Fix Version/s: V4.0_CSD02
    • Component/s: CSDL XML, URL Conventions
    • Labels:
      None
    • Environment:

      [Applied]

    • Proposal:
      Hide

      Rename edm:AssertType to edm:Cast

      Define cast rules:

      • cast primitive to string by using the literal representation used in payloads, and WKT for Geo types, fail if MaxLength is not sufficient
      • cast numeric primitives to each other with appropriate rounding, fail if integer part doesn't fit into target type
      • cast datetimeoffset, duration, or timeofday values to same type independent of precision
      • cast entities and complex type instances to derived type, fail if derived type adds non-nullable properties without default value
      • cast entities and complex type instances into arbitrary entity type or complex type by assigning values of identically named properties and casting them recursively, fail if non-nullable properties without default value remain without value
      • cast collections entry by entry

      If the cast fails, the result of the cast expression is null.

      Make edm:Cast optional for primitive values (first three rules).

      Provide a more informative example, see description

      The same rules apply to the cast() function in URL expressions.

      To increase consistency the edm:IsType expression could be renamed to edm:IsOf as it resembles the isof() function in URL expressions.

      Accepted: https://www.oasis-open.org/committees/download.php/49125/odata-meeting-36_on-20130509-minutes.html#odata-365

      Show
      Rename edm:AssertType to edm:Cast Define cast rules: cast primitive to string by using the literal representation used in payloads, and WKT for Geo types, fail if MaxLength is not sufficient cast numeric primitives to each other with appropriate rounding, fail if integer part doesn't fit into target type cast datetimeoffset, duration, or timeofday values to same type independent of precision cast entities and complex type instances to derived type, fail if derived type adds non-nullable properties without default value cast entities and complex type instances into arbitrary entity type or complex type by assigning values of identically named properties and casting them recursively, fail if non-nullable properties without default value remain without value cast collections entry by entry If the cast fails, the result of the cast expression is null. Make edm:Cast optional for primitive values (first three rules). Provide a more informative example, see description The same rules apply to the cast() function in URL expressions. To increase consistency the edm:IsType expression could be renamed to edm:IsOf as it resembles the isof() function in URL expressions. Accepted: https://www.oasis-open.org/committees/download.php/49125/odata-meeting-36_on-20130509-minutes.html#odata-365
    • Resolution:
      Show
      https://www.oasis-open.org/committees/download.php/49203/odata-v4.0-wd02-part3-csdl-2013-05-16.docx https://tools.oasis-open.org/version-control/browse/wsvn/odata/trunk/spec/schemas/edm.xsd?rev=297 https://tools.oasis-open.org/version-control/browse/wsvn/odata/trunk/spec/schemas/edm.xsd?rev=296 Accepted: https://www.oasis-open.org/committees/download.php/49557/odata-meeting-41_on-20130613_14-F2F-minutes.html#odata-365

      Description

      In most programming languages, an assertion is a predicate (a true-false statement) placed in a program to indicate that the developer thinks that the predicate is always true at that place. If the assertion is false, an assertion failure results, which typically causes execution to abort.

      In contrast the dynamic expression edm:AssertType behaves different: It casts the value of the child expression to the specified type. So the name edm:Cast would express this behaviour better. We must define the behaviour if the cast fails: I propose to return the NULL value as result of dynamic expression.

      The third proposal is to provide a more informative example in the specification, e.g.
      <Annotation Term="org.example.display.Threshold">
      <Cast Type="Edm.Decimal">
      <Path>Average</Path>
      </Cast>
      </Annotation>
      assume Average is of type edm:String an the Term is of type edm:PrimitiveType

        Attachments

          Activity

            People

            • Assignee:
              martinzurmuehl Martin Zurmuehl
              Reporter:
              martinzurmuehl Martin Zurmuehl
            • Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: