Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-22176

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

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 16.4.0-rc-1, 15.10.10
    • 16.3.1
    • Query
    • None
    • Unknown
    • N/A
    • N/A

    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;
      } 

      Attachments

        Activity

          People

            rjakse Raphaël Jakse
            rjakse Raphaël Jakse
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: