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

$1 references in URLs in batch requests #122

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from
Draft
32 changes: 19 additions & 13 deletions abnf/odata-abnf-construction-rules.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
;------------------------------------------------------------------------------
; OData ABNF Construction Rules Version 4.01 and 4.0
; OData ABNF Construction Rules Version 4.02, 4.01, and 4.0
;------------------------------------------------------------------------------
; 17 September 2020
; 05 February 2024
;
; Latest version: https://github.com/oasis-tcs/odata-abnf/blob/main/abnf/odata-abnf-construction-rules.txt
;------------------------------------------------------------------------------
Expand All @@ -21,18 +21,18 @@
;
; Additional artifacts:
; This grammar is one component of a Work Product which consists of:
; - OData Version 4.01 Part 1: Protocol
; - OData Version 4.01 Part 2: URL Conventions
; - OData ABNF Construction Rules Version 4.01 (this document)
; - OData ABNF Test Cases Version 4.01
; - OData Version 4.02 Part 1: Protocol
; - OData Version 4.02 Part 2: URL Conventions
; - OData ABNF Construction Rules Version 4.02 (this document)
; - OData ABNF Test Cases Version 4.02
;
; Related work:
; This specification replaces or supersedes:
; - OData ABNF Construction Rules Version 4.0
; This work product is related to
; - OData Common Schema Definition Language (CSDL) JSON Representation Version 4.01
; - OData Common Schema Definition Language (CSDL) XML Representation Version 4.01
; - OData JSON Format Version 4.01
; - OData Common Schema Definition Language (CSDL) JSON Representation Version 4.02
; - OData Common Schema Definition Language (CSDL) XML Representation Version 4.02
; - OData JSON Format Version 4.02
;
; Abstract:
; The Open Data Protocol (OData) enables the creation of REST-based data
Expand Down Expand Up @@ -344,7 +344,7 @@ inlinecount = ( "$count" / "count" ) EQ boolean

schemaversion = ( "$schemaversion" / "schemaversion" ) EQ ( STAR / 1*unreserved )

search = ( "$search" / "search" ) EQ BWS ( searchExpr / searchExpr-incomplete )
search = ( "$search" / "search" ) EQ BWS ( searchExpr / searchExpr-incomplete ) BWS

searchExpr = ( searchParenExpr
/ searchNegateExpr
Expand Down Expand Up @@ -372,7 +372,7 @@ searchPhrase = quotation-mark 1*( qchar-no-AMP-DQUOTE / SP ) quotation-mark
; Expressing this in ABNF is somewhat clumsy, so the following rule is overly generous.
; Note: the words AND, OR, and NOT are sometimes operators, depending on their position within a search expression.
searchWord = searchChar *( searchChar / SQUOTE )
searchChar = unreserved / pct-encoded-no-DQUOTE / "!" / "*" / "+" / "," / ":" / "@" / "/" / "?" / "$" / "="
searchChar = unreserved / pct-encoded-no-SP-DQUOTE / "!" / "*" / "+" / "," / ":" / "@" / "/" / "?" / "$" / "="

searchExpr-incomplete = SQUOTE *( SQUOTE-in-string / qchar-no-AMP-SQUOTE / quotation-mark / SP ) SQUOTE

Expand Down Expand Up @@ -525,6 +525,9 @@ rootExpr = %s"$root/" ( entitySetName [ collectionNavigationExpr ]

firstMemberExpr = memberExpr
/ inscopeVariableExpr [ "/" memberExpr ]
/ "$" request-id "/" memberExpr ; reference to single-valued response of earlier request
/ "$" request-id collectionNavigationExpr ; reference to collection-valued response of earlier request
/ "$" request-id

memberExpr = directMemberExpr
/ ( optionallyQualifiedEntityTypeName / optionallyQualifiedComplexTypeName ) "/" directMemberExpr
Expand Down Expand Up @@ -647,7 +650,7 @@ containsMethodCallExpr = "contains" OPEN BWS commonExpr BWS COMMA BW
endsWithMethodCallExpr = "endswith" OPEN BWS commonExpr BWS COMMA BWS commonExpr BWS CLOSE
indexOfMethodCallExpr = "indexof" OPEN BWS commonExpr BWS COMMA BWS commonExpr BWS CLOSE
lengthMethodCallExpr = "length" OPEN BWS commonExpr BWS CLOSE
matchesPatternMethodCallExpr = "matchesPattern" OPEN BWS commonExpr BWS COMMA BWS commonExpr BWS CLOSE
matchesPatternMethodCallExpr = "matchesPattern" OPEN BWS commonExpr BWS COMMA BWS commonExpr BWS [ COMMA BWS commonExpr BWS ] CLOSE
startsWithMethodCallExpr = "startswith" OPEN BWS commonExpr BWS COMMA BWS commonExpr BWS CLOSE
substringMethodCallExpr = "substring" OPEN BWS commonExpr BWS COMMA BWS commonExpr BWS [ COMMA BWS commonExpr BWS ] CLOSE
toLowerMethodCallExpr = "tolower" OPEN BWS commonExpr BWS CLOSE
Expand Down Expand Up @@ -1168,7 +1171,7 @@ COLON = ":" / "%3A"
COMMA = "," / "%2C"
EQ = "="
HASH = "%23" ; the # character is not allowed in the query part
SIGN = "+" / "%2B" / "-"
SIGN = "%2B" / "-"
SEMI = ";" / "%3B"
STAR = "*" / "%2A"
SQUOTE = "'" / "%27"
Expand Down Expand Up @@ -1260,6 +1263,9 @@ pct-encoded-unescaped = "%" ( "0" / "1" / "3" / "4" / "6" / "7" / "8" / "9"
pct-encoded-no-DQUOTE = "%" ( "0" / "1" / "3" / "4" / "5" / "6" / "7" / "8" / "9" / A-to-F ) HEXDIG
/ "%" "2" ( "0" / "1" / "3" / "4" / "5" / "6" / "7" / "8" / "9" / A-to-F )

pct-encoded-no-SP-DQUOTE = "%" ( "0" / "1" / "3" / "4" / "5" / "6" / "7" / "8" / "9" / A-to-F ) HEXDIG
/ "%" "2" ( "1" / "3" / "4" / "5" / "6" / "7" / "8" / "9" / A-to-F )


;------------------------------------------------------------------------------
; B. IRI syntax [RFC3987]
Expand Down
88 changes: 72 additions & 16 deletions abnf/odata-abnf-testcases.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# OData ABNF Test Cases Version 4.01 and 4.0
# OData ABNF Test Cases Version 4.02, 4.01, and 4.0
#
# 17 September 2020
# 05 February 2024
#
# Latest version: https://github.com/oasis-tcs/odata-abnf/blob/main/abnf/odata-abnf-testcases.yaml
#
Expand All @@ -19,18 +19,18 @@
#
# Additional artifacts:
# This test case document is one component of a Work Product which consists of:
# - OData Version 4.01 Part 1: Protocol
# - OData Version 4.01 Part 2: URL Conventions
# - OData ABNF Construction Rules Version 4.01
# - OData ABNF Test Cases Version 4.01 (this document)
# - OData Version 4.02 Part 1: Protocol
# - OData Version 4.02 Part 2: URL Conventions
# - OData ABNF Construction Rules Version 4.02
# - OData ABNF Test Cases Version 4.02 (this document)
#
# Related work:
# This specification replaces or supersedes:
# - OData ABNF Test Cases Version 4.0
# This work product is related to
# - OData Common Schema Definition Language (CSDL) JSON Representation Version 4.01
# - OData Common Schema Definition Language (CSDL) XML Representation Version 4.01
# - OData JSON Format Version 4.01
# - OData Common Schema Definition Language (CSDL) JSON Representation Version 4.02
# - OData Common Schema Definition Language (CSDL) XML Representation Version 4.02
# - OData JSON Format Version 4.02
#
# Abstract:
# The Open Data Protocol (OData) enables the creation of REST-based data
Expand All @@ -42,10 +42,10 @@
#
# Overview:
# This document contains positive and negative test cases for the
# OData ABNF Construction Rules Version 4.01.
# OData ABNF Construction Rules Version 4.02.
# Positive test cases consist of the rule to test, the input string to parse,
# and a description of the test case, often starting with a section number
# referring to OData Version 4.01 Part 2: URL Conventions.
# referring to OData Version 4.02 Part 2: URL Conventions.
# Negative test cases in addition state the character position at which the
# invalid portion of input text starts, 0 meaning the whole input string.
#
Expand Down Expand Up @@ -250,6 +250,10 @@ Constraints:
- Title
- X
- ZipCode
request-id:
- '1'
- First-Insert~Customer_1.1
- group1
singletonEntity:
- BestProductEverCreated
- MainSupplier
Expand Down Expand Up @@ -1921,6 +1925,10 @@ TestCases:
Rule: commonExpr
Input: matchesPattern(CompanyName,'%5EA.*e$')

- Name: 5.1.1.7.1 matchesPattern ^A.*e$ case-insensitive
Rule: commonExpr
Input: matchesPattern(CompanyName,'%5EA.*e$','i')

- Name: 5.1.1.7.2 tolower
Rule: commonExpr
Input: tolower(CompanyName)
Expand Down Expand Up @@ -2264,6 +2272,26 @@ TestCases:
Rule: odataRelativeUri
Input: Customers?$select=Addresses(@a=$this;$filter=endswith(@a/Street,'gasse'))

- Name: request reference in $batch
Rule: commonExpr
Input: Customer eq $1
Expect:
- firstMemberExpr:Customer
- firstMemberExpr:$1

- Name: property reference in $batch
Rule: commonExpr
Input: Customer/Name eq $1/Name
Expect:
- memberExpr:Customer/Name
- memberExpr:Name

- Name: member reference in $batch
Rule: commonExpr
Input: Customer/Name eq $1('ALFKI')/Name
Expect:
- collectionNavigationExpr:('ALFKI')/Name

- Name: 5.1.1.15 Path expressions
Rule: commonExpr
Input: Items
Expand Down Expand Up @@ -2741,6 +2769,26 @@ TestCases:
Rule: queryOptions
Input: $search=blue%20green

- Name: 5.1.7 Search - leading space
Rule: queryOptions
Input: $search=%20blue
Expect:
- searchWord:blue

- Name: 5.1.7 Search - trailing space
Rule: queryOptions
Input: $search=blue%20&!special
Expect:
- searchWord:blue
- customQueryOption:!special

- Name: 5.1.7 Search - space in search phrase
Rule: queryOptions
Input: $search=%20"%20"%20-%20
Expect:
- searchPhrase:"%20"
- searchWord:-

- Name: 5.1.7 Search - AND
Rule: queryOptions
Input: $search=blue AND green
Expand Down Expand Up @@ -3557,26 +3605,34 @@ TestCases:
Rule: header
Input: isolation:sNapShoT

- Name: Header - odata-maxversion
- Name: Header - odata-maxversion 4.0
Rule: header
Input: "odata-maxversion: 4.0"

- Name: Header - odata-maxversion next
- Name: Header - odata-maxversion 4.01
Rule: header
Input: "odata-maxversion: 4.01"

- Name: Header - odata-maxversion
- Name: Header - odata-maxversion 4.02
Rule: header
Input: "odata-maxversion: 4.02"

- Name: Header - odata-maxversion weird
Rule: header
Input: odata-maxversion:06.2831852000

- Name: Header - odata-version
- Name: Header - odata-version 4.0
Rule: header
Input: "odata-version: 4.0"

- Name: Header - odata-version
- Name: Header - odata-version 4.01
Rule: header
Input: "odata-version: 4.01"

- Name: Header - odata-version 4.02
Rule: header
Input: "odata-version: 4.02"

- Name: Preferences - allow entity references and maximum page size
Rule: prefer
Input: "Prefer: odata.allow-entityreferences,odata.maxpagesize=20"
Expand Down
2 changes: 2 additions & 0 deletions abnf/odata-aggregation-testcases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ Constraints:
- Total # dynamic
- WeightedAmount # dynamic
- Year
request-id:
- group1
streamProperty:
- Image
termName:
Expand Down
Loading