DBStringList SQL query issue

2 Messages Forum Options Options
Embed this topic
Permalink
Pascal Voitot
DBStringList SQL query issue
Reply Threaded MoreMore options
Print post
Permalink
Hello,
as you may now (or even may have coded), you can put a SQL query in a
DBStringList property...

something like
select prop.value from BaseObject as obj, StringProperty as prop where
obj.name = "mydocname" and obj.className="myclassname" and obj.id.id =
prop.id and prop.name = "mypropname"

but you can also use 2 columns (first one for stored value and second one
for displayed value)
select prop.value, prop2.value from BaseObject as obj, StringProperty as
prop, StringProperty as prop2 where obj.name = "mydocname" and
obj.className="myclassname" and obj.id.id = prop.id and prop.name =
"mypropname" and obj.id.id = prop2.id and prop2.name = "myprop2name"

So then I have tried something more complex
select prop.value, prop.value||prop2.value from BaseObject as obj,
StringProperty as prop, StringProperty as prop2 where obj.name = "mydocname"
and obj.className="myclassname" and obj.id.id = prop.id and prop.name =
"mypropname" and obj.id.id = prop2.id and prop2.name = "myprop2name"

or

select prop.value, concat(prop.value, prop2.value) from BaseObject as obj,
StringProperty as prop, StringProperty as prop2 where obj.name = "mydocname"
and obj.className="myclassname" and obj.id.id = prop.id and prop.name =
"mypropname" and obj.id.id = prop2.id and prop2.name = "myprop2name"

and it throws some funny errors... why? In DBStringListClass, makeList
transforms the SQL query to separate both columns and re-creates SQL query
with one column only. But apparently, it doesn't manage such expressions...
the funniest is "||" since it looks like it is rendered as a Wiki
expression...

regards
Pascal
_______________________________________________
devs mailing list
devs@...
http://lists.xwiki.org/mailman/listinfo/devs
Ludovic Dubost-2
Re: DBStringList SQL query issue
Reply Threaded MoreMore options
Print post
Permalink

Hi Pascal,

You should not use " but '

You can try your query in a page with $xwiki.search()

We have a bug in some version which does not allow to use "order by" in
your query

Ludovic

Pascal Voitot wrote:

> Hello,
> as you may now (or even may have coded), you can put a SQL query in a
> DBStringList property...
>
> something like
> select prop.value from BaseObject as obj, StringProperty as prop where
> obj.name = "mydocname" and obj.className="myclassname" and obj.id.id =
> prop.id and prop.name = "mypropname"
>
> but you can also use 2 columns (first one for stored value and second one
> for displayed value)
> select prop.value, prop2.value from BaseObject as obj, StringProperty as
> prop, StringProperty as prop2 where obj.name = "mydocname" and
> obj.className="myclassname" and obj.id.id = prop.id and prop.name =
> "mypropname" and obj.id.id = prop2.id and prop2.name = "myprop2name"
>
> So then I have tried something more complex
> select prop.value, prop.value||prop2.value from BaseObject as obj,
> StringProperty as prop, StringProperty as prop2 where obj.name = "mydocname"
> and obj.className="myclassname" and obj.id.id = prop.id and prop.name =
> "mypropname" and obj.id.id = prop2.id and prop2.name = "myprop2name"
>
> or
>
> select prop.value, concat(prop.value, prop2.value) from BaseObject as obj,
> StringProperty as prop, StringProperty as prop2 where obj.name = "mydocname"
> and obj.className="myclassname" and obj.id.id = prop.id and prop.name =
> "mypropname" and obj.id.id = prop2.id and prop2.name = "myprop2name"
>
> and it throws some funny errors... why? In DBStringListClass, makeList
> transforms the SQL query to separate both columns and re-creates SQL query
> with one column only. But apparently, it doesn't manage such expressions...
> the funniest is "||" since it looks like it is rendered as a Wiki
> expression...
>
> regards
> Pascal
> _______________________________________________
> devs mailing list
> devs@...
> http://lists.xwiki.org/mailman/listinfo/devs
>
>  


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

_______________________________________________
devs mailing list
devs@...
http://lists.xwiki.org/mailman/listinfo/devs