Uploaded image for project: 'Torque'
  1. Torque
  2. TORQUE-321

Wrong optimization of iLike without wildcards

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 4.0
    • 5.0
    • Runtime
    • None
    • Using java 8 and Postgresql 9.3.4.

    Description

      Torque transform a criteria with SqlEnum.ILIKE to a simple compare using(=) if the string it searches for don't contain any wildcards.

      But this optimization is not valid, because ILIKE also does a case insensitive compare. This bug causes ILIKE to behave like LIKE when not using any wildcards.

      Example code:
      Criteria c=new Criteria();
      c.and(VoucherinstancePeer.CODE,"myCode",SqlEnum.ILIKE);
      log.debug("Got criteria=" + c);
      c=new Criteria();
      c.and(VoucherinstancePeer.CODE,"myCode%",SqlEnum.ILIKE);
      log.debug("Got criteria=" + c);

      Gives this output:

      DEBUG - Got criteria=Criteria: Current Query SQL (may not be complete or applicable): SELECT FROM voucherInstance WHERE voucherInstance.code=? Replacements: [myCode]

      DEBUG - Got criteria=Criteria: Current Query SQL (may not be complete or applicable): SELECT FROM voucherInstance WHERE voucherInstance.code ILIKE ? Replacements: [myCode%]

      where the invalid transformation can be seen.

      Attachments

        Activity

          People

            tfischer Thomas Fox
            tiller Martin Tilsted
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: