Item10738: Confusion with QUERY 'string' IN (list) treating list as field names unless each item quoted

pencil
Priority: Normal
Current State: Confirmed
Released In: n/a
Target Release: minor
Applies To: Engine
Component: SEARCH
Branches:
Reported By: PaulAlexander
Waiting For: SvenDowideit
Last Change By: CrawfordCurrie
I would like to use QUERY to check a value against a list, like this

%QUERY{"'A' IN (A,B,C)"}%
The list would be the result of a QUERY,
%QUERY{"'A' IN (%QUERY{"D"}%)"}%

The problem is enclosing each list item within single quotes
%QUERY{"'A' IN ('A','B','C')"}%

Eg., works:
%QUERY{
  "'ArthurClemens' IN
  (%FORMAT{
    "%QUERY{"'Community.BrandLogoTalk'/attachments.user"}%"
    type="string"
    format="'$item'"
    separator=","
  }%)"
}%

Test: 1

Eg., doesn't work:
%QUERY{
  "'ArthurClemens' IN
  (%QUERY{"'Community.BrandLogoTalk'/attachments.user"}%)"
}%

Test: 0

-- PaulAlexander - 12 May 2011

So, I think the goal of this task should be either to improve the documentation (it took a few attempts to arrive at the solution above), or ... is there a way we could specify a quoted-comma-separated list output with QUERY? Thoughts?

-- PaulHarvey - 12 May 2011

I've adjusted Paul's example to use real data from a topic here on foswiki.org - and I know we could accomplish the same thing with
%QUERY{"'Community.BrandLogoTalk'/attachments[user='ArthurClemens']"}%
- I just encouraged this task being raised as it may potentially require clarification for others trying to use it when 1.2/2.0 is released

-- PaulHarvey - 12 May 2011

The right approach is definitely to support the quotifcation of lists returned from QUERY. Unfortunately both style="perl" and style="json" generate double-quoted strings, so style="tml" would be required.

-- CrawfordCurrie - 06 Jun 2011
 

ItemTemplate edit

Summary Confusion with QUERY 'string' IN (list) treating list as field names unless each item quoted
ReportedBy PaulAlexander
Codebase trunk
SVN Range
AppliesTo Engine
Component SEARCH
Priority Normal
CurrentState Confirmed
WaitingFor SvenDowideit
Checkins
TargetRelease minor
ReleasedIn n/a
Topic revision: r3 - 06 Jun 2011, CrawfordCurrie
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy