Spring Data MongoDB
  1. Spring Data MongoDB
  2. DATAMONGO-469

Query creation from method names using AND criteria does not work anymore

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.0.2
    • Fix Version/s: 1.0.3, 1.1 M2
    • Component/s: Repository
    • Labels:
      None

      Description

      When migrating from 1.0.1 to 1.0.2, one of my test failed.

      @Test
      public void testFindByPseudoAndPassword_wrongPseudo() {
          Member member = new Member("pseudo");
          member.setPassword("password");
      
          memberRepository.save(member);
      
          Member findMember = memberRepository.findByPseudoAndPassword("wrong-pseudo", "password");
          assertThat(findMember).isNull(); // FAILS HERE because the query retrieve the member with password equals "password" and miss the pseudo value
      }
      

      and the log is :

       DEBUG [MongoTemplate] findOne using query: { "password" : "password" , "$and" : [ { "password" : "password"}]} 

      I saw that in https://github.com/SpringSource/spring-data-mongodb/blob/1.0.x/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/query/MongoQueryCreatorUnitTests.java there is no assertion for the test #createsQueryCorrectly which test the Criteria AND case.

      May be it is due to https://github.com/SpringSource/spring-data-mongodb/commit/c8bb46ffb3b2ffa5456417a199ffa0d3b977bf0b

        Issue Links

          Activity

          Hide
          Oliver Gierke added a comment -

          Seems the handling of the And case was broken. Fix deployed to 1.0.x and 1.1.x branches.

          Show
          Oliver Gierke added a comment - Seems the handling of the And case was broken. Fix deployed to 1.0.x and 1.1.x branches.
          Hide
          shirish added a comment -

          This is still happening with versions 1.0.3 and 1.0.4

          Show
          shirish added a comment - This is still happening with versions 1.0.3 and 1.0.4
          Hide
          Oliver Gierke added a comment -

          Please keep this closed as the version the ticket is marked as fixed to is already released. Feel free to open another ticket providing a test case that shows using the And keyword still fails. Have a look at the test cases introduced with the fix fot this ticket in how far they are different from your scenario.

          Show
          Oliver Gierke added a comment - Please keep this closed as the version the ticket is marked as fixed to is already released. Feel free to open another ticket providing a test case that shows using the And keyword still fails. Have a look at the test cases introduced with the fix fot this ticket in how far they are different from your scenario.

            People

            • Assignee:
              Oliver Gierke
              Reporter:
              Ludovic Praud
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: