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日

Edit | Attach | (削除) Watch (削除ここまで) | Print version | History : r7 < r6 < r5 < r4 < r3 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r7 - 2010年03月21日 - PeterThoeny
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.

AltStyle によって変換されたページ (->オリジナル) /