OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

odata message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]

Subject: Re: [odata] Conflicting info for $count?

Hi Mark,

I do not see the conflict between the two use cases that share the token $count.

Case 1 /$count (token as <hierarchical part> URL member)
    is equivalent to a "SELECT count(...) ..." on SQL level.
Case 2 ?$count=true (token as <query> URL member)
    is an enrichment of the result set defined in <hierarchical part>.

So even a call like:


should work, albeit here ?$count=true would not really enrich the result set ;-)

All the best,
andAm 02.02.15 um 22:44 schrieb Mark Biamonte:
In looking into the changes from OData v2 to OData v4 for $count, I am
seeing what I believe is conflicting information.

In the OData v4 URL Conventions document, I find the following

To address the raw value of the number of items in a collection, clients
append/$countto the resource path of the URL identifying the entity set
or collection.  The count is calculated after applying any$filter
query options to the collection. The returned count MUST NOT be affected
by$top,$skip,$orderby, or$expand.

/Example 26: the number of related entities/


/Example 27: the number of entities in an entity set/


/Example 28: entity count in a$filter
Note that the spaces around//gt////are for readability of the example
only; in real URLs they must be percent-encoded as//%20//./

http://host/service/Categories?$filter=Products/$countgt 0

/Example 29: entity count in an$orderby


This says that $count returns the number of entities in the entity set,
but not the actual entities.

In the OData v4 Protocol document I find

The$countsystem query option with a value oftruespecifies that the total
count of items within a collection matching the request be returned
along with the result.

/Example 51: return, along with the results, the total number of
products in the collection/


The count of related entities can be requested by specifying
the$countquery option within the$expandclause.

/Example 52:/


A$countquery option with a value offalse(or not specified) hints that
the service SHOULD NOT return a count.

The service returns an HTTP Status code of400 Bad Requestif a value
other thantrueorfalseis specified.

The$countsystem query option ignores any$top
options, and returns the total count of results across all pages
including only those results matching any specified$filter
Clients should be aware that the count returned inline may not exactly
equal the actual number of items returned, due to latency between
calculating the count and enumerating the last value or due to inexact
calculations on the service.

How the count is encoded in the response body is dependent upon the
selected format.

This says the count is returned along with the entities in an entity set.

Which is the correct behavior for $count?



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]