This issue has been created
 
 
XWiki Platform / cid:jira-generated-image-avatar-1d62022b-edec-4fed-9e66-bd44c7266976 XWIKI-22176 Open

WrappingQuery's bindValue(s) methods unexpectedly return the wrapped query

 
View issue   ·   Add comment
 

Issue created

 
cid:jira-generated-image-avatar-ff1cc20f-3469-40bc-b437-e356457063ba Raphaël Jakse created this issue on 21/May/24 10:48
 
Summary: WrappingQuery's bindValue(s) methods unexpectedly return the wrapped query
Issue Type: cid:jira-generated-image-avatar-1d62022b-edec-4fed-9e66-bd44c7266976 Bug
Affects Versions: 16.3.1
Assignee: Unassigned
Components: Query
Created: 21/May/24 10:48
Priority: cid:jira-generated-image-static-major-d043220a-0512-49f7-8735-1151fad58d8f Major
Reporter: Raphaël Jakse
Description:

org.xwiki.query.WrappingQuery 's bindValue and bindValues methods return the wrapped query instead of the current query. This is unexpected and can lead to breakage in calling code expecting to get the wrapping query instead (which is the documented behavior in the JavaDoc).

Current implementation:

    @Override
    public Query bindValue(String var, Object val)
    {
        return getWrappedQuery().bindValue(var, val);
    }

    @Override
    public Query bindValue(int index, Object val)
    {
        return getWrappedQuery().bindValue(index, val);
    }

    @Override
    public Query bindValues(List<Object> values)
    {
        return getWrappedQuery().bindValues(values);
    }

    @Override
    public Query bindValues(Map<String, ?> values)
    {
        return getWrappedQuery().bindValues(values);
    } 

Suggested implementation:

@Override
public Query bindValue(String p, Object val)
{
    getWrappedQuery().bindValue(p, val);
    return this;
}

@Override
public Query bindValue(int index, Object val)
{
    getWrappedQuery().bindValue(index, val);
    return this;
}

@Override
public Query bindValues(List<Object> values)
{
    getWrappedQuery().bindValues(values);
    return this;
}

@Override
public Query bindValues(Map<String, ?> values)
{
    getWrappedQuery().bindValues(values);
    return this;
}