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?


I understand now.  Thanks Stefan and Gil.  I will go back and look at the doc to see if I just didn't read it right at first or if there is something that needs to be done to make the distinction clear

Mark

-----Original Message-----
From: odata@lists.oasis-open.org [mailto:odata@lists.oasis-open.org] On Behalf Of Stefan Drees
Sent: Tuesday, February 03, 2015 1:54 AM
To: odata@lists.oasis-open.org
Cc: Stefan Hagen
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:

http://host/service/Products/$count?$count=true

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

All the best,
Stefan.
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 
> <http://docs.oasis-open.org/odata/odata/v4.0/errata02/os/complete/part
> 2-url-conventions/odata-v4.0-errata02-os-part2-url-conventions-complet
> e.html#_Filter_System_Query>or$search
> <http://docs.oasis-open.org/odata/odata/v4.0/errata02/os/complete/part
> 2-url-conventions/odata-v4.0-errata02-os-part2-url-conventions-complet
> e.html#_Format_System_Query>system
> 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/
>
> http://host/service/Categories(1)/Products/$count
>
> /Example 27: the number of entities in an entity set/
>
> http://host/service/Products/$count
>
> /Example 28: entity count in a$filter
> <http://docs.oasis-open.org/odata/odata/v4.0/errata02/os/complete/part2-url-conventions/odata-v4.0-errata02-os-part2-url-conventions-complete.html#_System_Query_Option>expression.
> 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 
> <http://docs.oasis-open.org/odata/odata/v4.0/errata02/os/complete/part
> 2-url-conventions/odata-v4.0-errata02-os-part2-url-conventions-complet
> e.html#_OrderBy_System_Query>expression/
>
> http://host/service/Categories?$orderby=Products/$count
>
>
> 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/
>
> http://host/service/Products?$count=true
>
> The count of related entities can be requested by specifying 
> the$countquery option within the$expandclause.
>
> /Example 52:/
>
> http://host/service/Categories?$expand=Products($count=true)
>
> 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 
> <http://docs.oasis-open.org/odata/odata/v4.0/errata02/os/complete/part
> 1-protocol/odata-v4.0-errata02-os-part1-protocol-complete.html#_The_$t
> op_System_1>,$skip 
> <http://docs.oasis-open.org/odata/odata/v4.0/errata02/os/complete/part
> 1-protocol/odata-v4.0-errata02-os-part1-protocol-complete.html#_The_$s
> kip_System>,
> or$expand
> <http://docs.oasis-open.org/odata/odata/v4.0/errata02/os/complete/part
> 1-protocol/odata-v4.0-errata02-os-part1-protocol-complete.html#_System
> _Query_Option_6>query options, and returns the total count of results 
> across all pages including only those results matching any 
> specified$filter 
> <http://docs.oasis-open.org/odata/odata/v4.0/errata02/os/complete/part
> 1-protocol/odata-v4.0-errata02-os-part1-protocol-complete.html#_The_$f
> ilter_System>and$search 
> <http://docs.oasis-open.org/odata/odata/v4.0/errata02/os/complete/part1-protocol/odata-v4.0-errata02-os-part1-protocol-complete.html#_The_$format_System>.
> 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?
>
> Thanks
>
> Mark
>


---------------------------------------------------------------------
To unsubscribe from this mail list, you must leave the OASIS TC that generates this mail.  Follow this link to all your TCs in OASIS at:
https://www.oasis-open.org/apps/org/workgroup/portal/my_workgroups.php 



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