With Raffaello we found a MySQL bug that can make this query return an 
empty result set in MySQL 5.
There is a workwround by writing the query this way

#set($sql = ", BaseObject as obj, DBStringListProperty as prop join 
prop.list list where obj.name=doc.fullName and obj.id=prop.id.id and 
prop.id.name='tags' and list = 'KB-4D'")

The same type of join  or an in query should probably be used instead of 
using elements(prop.list) which seems to generate some sql that MySQL 
does not want to handle propertly.

So this would be:

#set($sql = "select distinct elements(prop.list) from BaseObject as obj, 
DBStringListProperty as prop where
obj.className='XWiki.TagClass' and obj.id=prop.id.id and prop.id.name='tags' 
and obj.name in (select obj1.name from BaseObject as obj1, DBStringListProperty 
as prop1 join prop1.list list
where obj1.id=prop1.id.id and prop1.id.name='tags' and list = 'KB-4D')")
#set ($tags = $xwiki.search($sql))

Ludovic

Jean-Vincent Drean wrote:

> On Thu, Aug 28, 2008 at 4:08 PM, Bruno Neves <[EMAIL PROTECTED]> wrote:
>   
>> Greetings
>>
>> My objective is to list every document with some tag (e.g. "MainTag"), and 
>> next, select all tags of these
>> documents without repeating any of them  (including "MainTag").
>>
>> I tried to merge the next two queries but without sucess.
>>
>> This query selects every document that have the tag "KB-4D":
>>
>> #set($sql = ", BaseObject as obj, DBStringListProperty as prop where 
>> obj.name=doc.fullName and
>> obj.className='XWiki.TagClass' and obj.id=prop.id.id and prop.id.name='tags' 
>> and 'KB-4D' in
>> elements(prop.list) order by doc.name asc")
>> #set ($list = $xwiki.searchDocuments($sql))
>>
>>
>> This query selects every tags present in the documents listed by the 
>> previous query:
>>
>> #set($sql = "select distinct elements(prop.list) from BaseObject as obj, 
>> DBStringListProperty as prop where
>> obj.className='XWiki.TagClass' and obj.id=prop.id.id and prop.id.name='tags' 
>> and obj.name='$item'")
>> #set ($tags = $xwiki.search($sql))
>>
>> Can anyone help me with this?
>>     
>
> This should do the trick (require programming rights) :
>
> #set($sql = "select distinct elements(prop.list) from XWikiDocument as
> doc, BaseObject as obj, DBStringListProperty as prop where
> obj.name=doc.fullName and obj.className='XWiki.TagClass' and
> obj.id=prop.id.id and prop.id.name='tags' and 'KB-4D' in
> elements(prop.list) order by doc.name asc")
> #set ($list = $xwiki.search($sql))
>
>   
>> PS: How can I put snippet code on code.xwiki.org? I need to login but I am 
>> not registered.
>>
>>     
>
> You can register from http://www.xwiki.org
>
>   


-- 
Ludovic Dubost
Blog: http://blog.ludovic.org/
XWiki: http://www.xwiki.com
Skype: ldubost GTalk: ldubost

_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to