[xwiki-devs] [VOTE] Allow to filter query result lists with QueryFilter (new API)
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.
On Wed, May 2, 2012 at 6:28 PM, Jean-Vincent Drean <[email protected]> wrote:
Hi,
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.
As Thomas pointed out in a recent discussion the fact that the result list can be heavily modified by the filter (and indeed I already have a filter transforming List<Object[]> to List<String>) doesn't match with the API signature. I'd like to modify the proposal: ====================8<==================== /** * Filter a list of query results. The result list can be returned without modification. * * @param results the original result list. * @return a filtered result list. */ List filterResults(List results); ====================8<==================== -- Jean-Vincent Drean, XWiki.
+1 On Fri, May 4, 2012 at 12:06 PM, Jean-Vincent Drean <[email protected]> wrote:
On Wed, May 2, 2012 at 6:28 PM, Jean-Vincent Drean <[email protected]> wrote:
Hi,
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.
As Thomas pointed out in a recent discussion the fact that the result list can be heavily modified by the filter (and indeed I already have a filter transforming List<Object[]> to List<String>) doesn't match with the API signature. I'd like to modify the proposal:
====================8<==================== /** * Filter a list of query results. The result list can be returned without modification. * * @param results the original result list. * @return a filtered result list. */ List filterResults(List results); ====================8<====================
-- Jean-Vincent Drean, XWiki. _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne
On Fri, May 4, 2012 at 1:06 PM, Jean-Vincent Drean <[email protected]> wrote:
On Wed, May 2, 2012 at 6:28 PM, Jean-Vincent Drean <[email protected]> wrote:
Hi,
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.
As Thomas pointed out in a recent discussion the fact that the result list can be heavily modified by the filter (and indeed I already have a filter transforming List<Object[]> to List<String>) doesn't match with the API signature. I'd like to modify the proposal:
====================8<==================== /** * Filter a list of query results. The result list can be returned without modification. * * @param results the original result list. * @return a filtered result list. */
List filterResults(List results);
List<?> filterResults(List<?> results); to avoid the warnings? Thanks, Marius
====================8<====================
-- Jean-Vincent Drean, XWiki. _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
On Fri, May 4, 2012 at 5:55 PM, Marius Dumitru Florea <[email protected]> wrote:
On Fri, May 4, 2012 at 1:06 PM, Jean-Vincent Drean <[email protected]> wrote:
On Wed, May 2, 2012 at 6:28 PM, Jean-Vincent Drean <[email protected]> wrote:
Hi,
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.
As Thomas pointed out in a recent discussion the fact that the result list can be heavily modified by the filter (and indeed I already have a filter transforming List<Object[]> to List<String>) doesn't match with the API signature. I'd like to modify the proposal:
====================8<==================== /** * Filter a list of query results. The result list can be returned without modification. * * @param results the original result list. * @return a filtered result list. */
List filterResults(List results);
List<?> filterResults(List<?> results);
to avoid the warnings?
We could but I don't think we need to. We're are already suppressing this warning in the query executor because of the Query#list() method which returns a plain List. https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwik...
Thanks, Marius
====================8<====================
-- Jean-Vincent Drean, XWiki. _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Jean-Vincent Drean, XWiki.
participants (3)
-
Jean-Vincent Drean -
Marius Dumitru Florea -
Thomas Mortagne