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

Add /$count support for $select #2050

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Add /$count support for $select #2050

wants to merge 2 commits into from

Conversation

mikepizzo
Copy link
Contributor

Fixes #2046

@mikepizzo mikepizzo self-assigned this Feb 19, 2025
@@ -2017,7 +2017,8 @@ properties of the identified instances of a structured type, optionally followed
related entity or entities, optionally followed by a [type-cast segment](#AddressingDerivedTypes)
to expand only related entities of that derived type or one of its
sub-types, optionally followed by `/$ref` to expand only entity
references.
references, or `/$count`, optionally with expand options, to return only the count of
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
references, or `/$count`, optionally with expand options, to return only the count of
references, or `/$count`, optionally with expand options [#OData-Protocol#ExpandOptions], to return only the count of

http://host/service/Categories?$expand=Products($filter=DiscontinuedDate eq null)
```
:::

The `$count` segment can be appended to a navigation property name or
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this paragraph a repetition of the third bullet point above?

Comment on lines +2076 to 2081
The [Expand Options](#ExpandOptions) [`$filter`](#SystemQueryOptionfilter),
[`$search`](#SystemQueryOptionsearch),
[`$skip`](#SystemQueryOptionstopandskip),
[`$top`](#SystemQueryOptionstopandskip), and
[`$count`](#SystemQueryOptioncount) can be used to limit the number of
[`$count`](#SystemQueryOptioncount) can be used to include the count of
expanded entity references.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The [Expand Options](#ExpandOptions) [`$filter`](#SystemQueryOptionfilter),
[`$search`](#SystemQueryOptionsearch),
[`$skip`](#SystemQueryOptionstopandskip),
[`$top`](#SystemQueryOptionstopandskip) can be used to limit the collection of expanded entity references, and
[`$count`](#SystemQueryOptioncount) can be used to include not the entity references themselves
but their count.

@@ -2207,7 +2211,7 @@ grammar of the `$select` query option.

The value of `$select` is a comma-separated list of select items. Each
select item is one of the following:
- a path, to include a property,
- a path, optionally followed by a count segment or select options
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- a path, optionally followed by a count segment or select options
- a path, optionally followed by a [count segment](#AddressingtheCountofaCollection) or [select options](#SelectOptions)

select options specified in more than one place in a request and MUST
NOT be specified in more than one expand.
If the path ends in a collection of primitive or complex values,
then the count segment (`/$count`), optionally followed by the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
then the count segment (`/$count`), optionally followed by the
then the [count segment](#AddressingtheCountofaCollection) (`/$count`), optionally followed by the

@@ -2370,6 +2373,39 @@ of properties, open properties, navigation properties, actions and
functions to be returned is equal to the union of the set of those
identified by each select item.

#### ##subsubsubsec SelectOptions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#### ##subsubsubsec SelectOptions
#### ##subsubsubsec Select Options

Comment on lines +2154 to +2164
Allowed system query options are
[`$compute`](#SystemQueryOptioncompute),
[`$select`](#SystemQueryOptionselect),
`$expand`, and
[`$levels`](#ExpandOptionlevels) for all navigation properties, plus
[`$filter`](#SystemQueryOptionfilter),
[`$orderby`](#SystemQueryOptionorderby),
[`$skip`](#SystemQueryOptionstopandskip), [`$top`](#SystemQueryOptionstopandskip),
[`$count`](#SystemQueryOptioncount), and
[`$search`](#SystemQueryOptionsearch)
for collection-valued navigation properties.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this an explicit list whereas section "Select Options" below refers to section "System Query Options"?

[System Query Options](#SystemQueryOptions), with the exception of
[`$expand`](#SystemQueryOptionexpand). 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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does "more than one expand" mean, given that $expand is ruled out above?

@@ -2224,7 +2228,7 @@ properties defined on the derived type.
A path can end with
- the name of a property or
non-entity-valued instance annotation of the identified
instance of a structured type,
instance of a structured type
Copy link
Contributor

@ralfhandl ralfhandl Feb 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
instance of a structured type
instance of a structured type,

same as in other bullet points

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Review
Development

Successfully merging this pull request may close these issues.

$select should support /$count and ($count=true) for collection-valued structural properties
3 participants