Allowing dblist queries to be scriptable

Hi everyone,

I have currently a use case in mind where having scriptable dblist queries could possibly be handy, not sure, but I was wondering if this is something that was considered already / if it could be beneficial to others, if not too complex to implement. The idea would be to allow the usage of Velocity code in the Database List class property query field. The provided query would then get evaluated before executing the query itself, so that the query could be refined depending on the context where it is used.

Example: movies, represented by MovieClass, consist of several stages (StageClass). Several movie pages get created in distinct spaces, and MovieClass contains a dblist property pointing at StageClass instances. When editing a movie, only the stages that are in the same location as the current movie should be listed, not all the ones existing in the wiki. Typically in that situation, having a dblist clause such as and doc.location like '$' or something along this line could spare creating a custom displayer or resorting to other more advanced techniques.

What do you think?


Well according to the code it’s already the case as long as the xclass document author has SCRIPT right.

1 Like

I didn’t even dare trying before asking the question but I confirm it’s working already, that’s great news as it opens the path to even more dynamic applications. I started adding a note about this feature in the database list field section of the XWiki Data Model documentation.

@tmortagne, all,

The feature is working fine on XWiki Standard 11.10 with HSQL but I’m having trouble getting it working on XWiki 10.11.9 + MySQL (XWiki Cloud instance), without much logging information so far (the query is just not executed any more when adding a scripted clause, a clause that works fine on a local 11.10 instance). Would you know if the functionality is supposed to work in 10.11.9? Would you have any pointer at the direct code location?


PS: the scripted clause I’m testing at the moment is as follows, in the HQL field:

select doc.fullName, doc.title from XWikiDocument as doc, BaseObject as obj where = doc.fullName and obj.className = 'Process.StepClass' and <> 'StepTemplate' and like '$' order by doc.title