Hi,
I'd like to introduce a new API in QueryFilter:
====================8<====================
/**
* Filter a list of query results. The result list can be returned
without modification.
*
* @param results the original result list.
* @param <T> expected type of elements in the result list.
* @return a filtered result list.
*/
<T> List<T> filterResults(List<T> results);
====================8<====================
In addition to QueryFilter#filterStatement(), this method would be
called from the QueryExecutor and it would allow the filter to mofidy
the result list of a query.
We talked about this one before with Thomas and Vincent but the use
case we were thinking about wasn't achievable (permission checking)
because of performance issues.
Now I need this method to fix an issue with the "unique" (distinct)
filter. When using "unique", a HSQLDB limitation [1] forces us to put
the columns present in the "order by" clause in the "select" clause.
This currently causes a lot of queries to fail when using the "unique"
filter. The fix consists to add the columns from the "order by" clause
in the "select" clause and then to remove the added columns from the
query results.
I think this new API fits well in the QueryResult interface, here's my +1.
[1] This is considered invalid when backed by HSQLDB (and Oracle
AFAIK): "select distinct doc.fullName from XWikiDocument order by
doc.language"
The reason is that the order can't be undoubtedly determined, for
example with the following data:
XWD_FULLNAME, XWD_LANGUAGE
Main.Page1, de
Main.Page1, fr
Main.Page2, en
Main.Page2, it
--
Jean-Vincent Drean,
XWiki.