Uploaded image for project: '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
    • Status: Closed
    • Priority: 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

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                olivergierke Oliver Gierke
                Reporter:
                ludovic.praud Ludovic Praud
                Last updater:
                Trevor Marshall
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: