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

Case statement ambiguous with timeOfDay values

    XMLWordPrintable

    Details

    • Proposal:
      Hide

      The use of the case statement without the optional whitespace and with timeofday values could be ambiguous. Clients should use whitespace or parens to disambiguate.

      Show
      The use of the case statement without the optional whitespace and with timeofday values could be ambiguous. Clients should use whitespace or parens to disambiguate.
    • Resolution:
      Show
      https://github.com/oasis-tcs/odata-specs/pull/149

      Description

      Our rules for the Case statement use colons to separate the condition from the value-if-true and value-if-false:

      caseMethodCallExpr = "case" OPEN BWS boolCommonExpr BWS COLON BWS commonExpr BWS 
                              *( COMMA BWS boolCommonExpr BWS COLON BWS commonExpr BWS ) CLOSE
      

      However, timeOfDay also uses colons to separate the parts of a time of day value, including optional seconds:

      timeOfDayValueInUrl = hour COLON minute [ COLON second [ "." fractionalSeconds ] ]

      That means that, for certain time of day values, the case statement could be ambiguous. i.e.;

      case(CreatedTime eq 10:20:15:10:10,15:20)

      which could legally be parsed any of the following ways:
        if CreatedTime eq 10:20 then 15:10:10 otherwise 15:20
        if CreatedTime eq 10:20:15 then 10:10 otherwise 15:20

      Note that the user could differentiate between these by inserting whitespace before/after the separators separating the case parameters:
        case(CreatedTime eq 10:20 : 15:10:10 : 15:20)
        case(CreatedTime eq 10:20:15 : 10:10 : 15:20)

        Attachments

          Activity

            People

            • Assignee:
              handl Ralf Handl
              Reporter:
              mikep Michael Pizzo (Inactive)
            • Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: