Feature Proposal: Query Syntax with .arraysize for Arrays
Motivation
The current
QuerySearch has arrays for form fields (META:FIELD), attachments (META:FILEATTACHMENT) and preferences (META:PREFERENCE). It is currently not possible to query the number of items in an array, say to test for the number of attachments in a page.
Description and Documentation
Add a
.arraysize to arrays. For example,
attachments.arraysize and
META:FILEATTACHMENT.arraysize returns the number of attachments,
fields.arraysize and
META:FIELD.arraysize return the number of form fields.
Examples
This is related to
QuerySyntaxInSearchFormat. With both implemented it is possible to return the number of attachments in a topic:
%SEARCH{ "%TOPIC%" scope="topic" nonoise="on" format="Number of attachments: $query(attachments.arraysize)" }%
This returns the number of .gif files attached to the topic:
%SEARCH{ "%TOPIC%" scope="topic" nonoise="on" format="Number of attachments: $query(attachments[name~'*gif'].arraysize)" }%
Impact
Implementation
--
Contributors: PeterThoeny - 2010-02-09
Discussion
I changed the syntax from
.size to
.arraysize to avoid ambiguity between:
-
attachments[name~'*.gif'].size -- "array with sizes of all .gif attachments", such as 1234, 567, 1372
and:
-
attachments[name~'*.gif'].arraysize -- "number of all .gif attachments", such as 3
--
PeterThoeny - 2010-02-09
This looks good proposal - i support this.
--
SopanShewale - 2010-02-10
I checked in the code and doc. Doc is at
http://develop.twiki.org/~twiki4/cgi-bin/view/TWiki/QuerySearch
--
PeterThoeny - 2010-02-16