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

[Clarification] Semantics & handling of duplicate query options values #2004

Closed
falbert-ptc opened this issue Sep 26, 2024 · 3 comments · Fixed by #2008
Closed

[Clarification] Semantics & handling of duplicate query options values #2004

falbert-ptc opened this issue Sep 26, 2024 · 3 comments · Fixed by #2008
Labels
URL Conventions URL Conventions

Comments

@falbert-ptc
Copy link

Let's take the following examples:

  1. /People?$select=Name,Name
  2. /People?$orderby=Age asc,Age desc
  3. /People?$expand=Relatives($filter=Married eq true),Relatives($filter=Married eq false)

Grammatically, the requests above are correct (per the ABNF. ).

Semantically however, they are confusing and/or full of contradictions.
Is there any guidance about how OData services should handle duplicate expandItem/orderbyItem/etc. ?

The current example TripIn service does not error out, but only considers the last item. Not sure if that's intended or an oversight.
Ex: https://services.odata.org/V4/TripPinService/People?$select=UserName&$expand=Trips($select=TripId,Name),Trips($filter=Name eq 'Gradutaion trip'),Trips($filter=Name eq 'Trip in US')

@ralfhandl
Copy link
Contributor

ralfhandl commented Sep 27, 2024

First, 5.1 System Query Options states that

The same system query option, irrespective of casing or whether or not it is prefixed with a $, MUST NOT be specified more than once for any resource.

We could, and probably should repeat that statement for nested query options in $expand and $select, see #2008.

5.1.3 System Query Option $expand states that

A path MUST NOT appear in more than one expand item.

This rules out example 3 above.

5.1.4 System Query Option $select does not exclude specifying a selected property more than once because it doesn't harm to say "I want this" more than once.

It does explicitly exclude duplicate or conflicting nested options:

The same property MUST NOT have select options specified in more than one place in a request and MUST NOT be specified in more than one expand.

11.2.6.2 System Query Option $orderby states that

Items are sorted by the result values of the first expression, and then items with the same value for the first expression are sorted by the result value of the second expression, and so on.

This means that specifying a property more than once does not have an effect on the outcome because it would sort items with the same value of the expression, and servers can just drop repeated expressions.

5.1.10 System Query Option $compute states that

[The name of the computed dynamic property] MUST differ from the names of declared or dynamic properties of the identified resources.

Which includes names of other computed dynamic properties.

Does this (with the addition of #2008) answer your question?

@falbert-ptc
Copy link
Author

Hello @ralfhandl

Yes it does, thank you very much !
I missed some of these (especially "A path MUST NOT appear in more than one expand item."), and I apologize.

Thanks again for the quick and clear response.

@ralfhandl
Copy link
Contributor

Hi @falbert-ptc,

Please don't apologize, we are grateful for any feedback.

If you have proposals to increase readability and making such statements easier to find, please don't hesitate to tell us.

It is really hard for us to fix readability issues - we know that something is written somewhere, which makes it easier to find 🙄

Thanks in advance
Ralf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
URL Conventions URL Conventions
Projects
Status: Closed
Development

Successfully merging a pull request may close this issue.

2 participants