Uploaded image for project: 'Infinispan'
  1. Infinispan
  2. ISPN-3442

Query API DSL returns bad result on calling negated between() with includeUpper/Lower(false)

This issue belongs to an archived project. You can view it, but you can't modify it. Learn more

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 6.0.0.Final
    • 6.0.0.Final
    • Embedded Querying
    • None

      Assuming existing of three users with IDs 1,2 and 3.
      Then this code's result is incorrect.

      Query q = queryFactory.from(User.class)
                  .not().having("id").between(1, 2).includeLower(false)
                  .toBuilder().build();
      

      It returns no user whereas it should return two users with IDs 1 and 3. I debugged the org.infinispan.query.dsl.impl.JPAQueryGeneratorVisitor and found the problem in visit(BetweenOperator operator).

      The code correctly changes the </<= and >/>= operators if between operator is negated, but forgets to change "AND" to "OR".
      Thus the generated string query ends up like "id <= 1 AND id > 2" which is of course always empty result.

      The pull request contains fix to this bug and also extended tests for Query API DSL to increase code coverage.

              jholusa Jiří Holuša (Inactive)
              jholusa Jiří Holuša (Inactive)
              Archiver:
              rhn-support-adongare Amol Dongare

                Created:
                Updated:
                Resolved:
                Archived: