Default: @["modified_at desc", "uuid asc"]@|query|
|select |array |Attributes of each object to return in the response (by default, all available attributes are returned, except collections, which do not return @manifest_text@ unless explicitly selected).
Example: @["uuid","name","modified_at"]@|query|
-|distinct|boolean|@true@: (default) do not return duplicate objects
-@false@: permitted to return duplicates|query|
+|distinct|boolean|When returning multiple records whose whose selected attributes (see @select@) are equal, return them as a single response entry.
+Default is @false@.|query|
|count|string|@"exact"@ (default): Include an @items_available@ response field giving the number of distinct matching items that can be retrieved (irrespective of @limit@ and @offset@ arguments).
@"none"@: Omit the @items_available@ response field. This option will produce a faster response.|query|
@objects = @objects.order(@orders.join ", ") if @orders.any?
@objects = @objects.limit(@limit)
@objects = @objects.offset(@offset)
- @objects = @objects.distinct(@distinct) if not @distinct.nil?
+ @objects = @objects.distinct() if @distinct
end
# limit_database_read ensures @objects (which must be an
where: { type: 'object', required: false },
order: { type: 'array', required: false },
select: { type: 'array', required: false },
- distinct: { type: 'boolean', required: false },
+ distinct: { type: 'boolean', required: false, default: false },
limit: { type: 'integer', required: false, default: DEFAULT_LIMIT },
offset: { type: 'integer', required: false, default: 0 },
count: { type: 'string', required: false, default: 'exact' },
end
end
- @distinct = true if (params[:distinct] == true || params[:distinct] == "true")
- @distinct = false if (params[:distinct] == false || params[:distinct] == "false")
+ @distinct = params[:distinct] && true
end
def load_select_param
end
test "fewer distinct than total count" do
+ get "/arvados/v1/links",
+ params: {:format => :json, :select => ['link_class']},
+ headers: auth(:active)
+ assert_response :success
+ distinct_unspecified = json_response['items']
+
get "/arvados/v1/links",
params: {:format => :json, :select => ['link_class'], :distinct => false},
headers: auth(:active)
assert_response :success
- links = json_response['items']
+ distinct_false = json_response['items']
get "/arvados/v1/links",
params: {:format => :json, :select => ['link_class'], :distinct => true},
assert_response :success
distinct = json_response['items']
- assert_operator(distinct.count, :<, links.count,
- "distinct count should be less than link count")
- assert_equal links.uniq.count, distinct.count
+ assert_operator(distinct.count, :<, distinct_false.count,
+ "distinct=true count should be less than distinct=false count")
+ assert_equal(distinct_unspecified.count, distinct_false.count,
+ "distinct=false should be the default")
+ assert_equal distinct_false.uniq.count, distinct.count
end
test "select with order" do