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

Should be able to $orderby using filtered reverse navigation properties #824

Open
thgreasi opened this issue Oct 16, 2024 · 0 comments
Open

Comments

@thgreasi
Copy link
Member

thgreasi commented Oct 16, 2024

$orderby=device_tag(tag_key=%27test_key%27)/value%20desc
$orderby=device_tag(tag_key='test_key')/value desc

Afaict this is the OData spec path that allows this
See: https://docs.oasis-open.org/odata/odata/v4.01/os/abnf/odata-abnf-construction-rules.txt

orderby     = ( "$orderby" / "orderby" ) EQ orderbyItem *( COMMA orderbyItem )
orderbyItem = commonExpr [ RWS ( "asc" / "desc" ) ]

commonExpr = ( primitiveLiteral
             / arrayOrObject
             / rootExpr
             / firstMemberExpr // <----------
             / functionExpr
             / negateExpr 
             / methodCallExpr 
             / parenExpr 
             / castExpr 
             / isofExpr
             / notExpr
             ) 
             [ addExpr 
             / subExpr 
             / mulExpr 
             / divExpr
             / divbyExpr 
             / modExpr
             ]  
             [ eqExpr 
             / neExpr 
             / ltExpr  
             / leExpr  
             / gtExpr 
             / geExpr 
             / hasExpr 
             / inExpr 
             ]
             [ andExpr 
             / orExpr 
             ] 

firstMemberExpr = memberExpr // <----------
                / inscopeVariableExpr [ "/" memberExpr ]

memberExpr = directMemberExpr // <----------
           / ( optionallyQualifiedEntityTypeName / optionallyQualifiedComplexTypeName ) "/" directMemberExpr

directMemberExpr = propertyPathExpr // <----------
                 / boundFunctionExpr 
                 / annotationExpr

propertyPathExpr = ( entityColNavigationProperty [ collectionNavigationExpr ] // <----------
                   / entityNavigationProperty    [ singleNavigationExpr ] 
                   / complexColProperty          [ complexColPathExpr ]
                   / complexProperty             [ complexPathExpr ] 
                   / primitiveColProperty        [ collectionPathExpr ]
                   / primitiveProperty           [ primitivePathExpr ]
                   / streamProperty              [ primitivePathExpr ]

entityColNavigationProperty = odataIdentifier

collectionNavigationExpr = [ "/" optionallyQualifiedEntityTypeName ]
                           ( collectionPathExpr
                           / keyPredicate [ singleNavigationExpr ] // <-----
                           / filterExpr [ collectionNavigationExpr ]
                           )

// keyPredicate section:
keyPredicate     = ( simpleKey
                               / compoundKey // <-----
                              / keyPathSegments
                              )
compoundKey      = OPEN keyValuePair *( COMMA keyValuePair ) CLOSE
keyValuePair     = ( primitiveKeyProperty / keyPropertyAlias  ) EQ ( parameterAlias / keyPropertyValue )
primitiveKeyProperty    = odataIdentifier
EQ     = "="
keyPropertyValue = primitiveLiteral

// singleNavigationExpr section:
singleNavigationExpr = "/" memberExpr

memberExpr = directMemberExpr // <----------
           / ( optionallyQualifiedEntityTypeName / optionallyQualifiedComplexTypeName ) "/" directMemberExpr

directMemberExpr = propertyPathExpr // <----------
                 / boundFunctionExpr 
                 / annotationExpr

propertyPathExpr = ( entityColNavigationProperty [ collectionNavigationExpr ]
                   / entityNavigationProperty    [ singleNavigationExpr ] 
                   / complexColProperty          [ complexColPathExpr ]
                   / complexProperty             [ complexPathExpr ] 
                   / primitiveColProperty        [ collectionPathExpr ]
                   / primitiveProperty           [ primitivePathExpr ] // <----------
                   / streamProperty              [ primitivePathExpr ]

primitiveProperty       = primitiveKeyProperty / primitiveNonKeyProperty
primitiveKeyProperty    = odataIdentifier

See: https://balena.zulipchat.com/#narrow/stream/346007-balena-io.2FbalenaCloud/topic/Server.20side.20device.20list.20-.20cycle.204/near/477162968

See: #577

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

No branches or pull requests

1 participant