Skip to content

Commit 086d1e6

Browse files
Added a failing test - but unsure how to proceed with the fix
1 parent 18e00a9 commit 086d1e6

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/query/MongoQueryCreator.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package org.springframework.data.mongodb.repository.query;
1717

18+
import static java.util.Objects.nonNull;
1819
import static org.springframework.data.mongodb.core.query.Criteria.*;
1920

2021
import java.util.Arrays;
@@ -55,6 +56,7 @@
5556
* @author Oliver Gierke
5657
* @author Thomas Darimont
5758
* @author Christoph Strobl
59+
* @author Edward Prentice
5860
*/
5961
class MongoQueryCreator extends AbstractQueryCreator<Query, Criteria> {
6062

@@ -299,7 +301,8 @@ private Criteria createLikeRegexCriteriaOrThrow(Part part, MongoPersistentProper
299301
criteria = criteria.not();
300302
}
301303

302-
return addAppropriateLikeRegexTo(criteria, part, parameters.next().toString());
304+
return addAppropriateLikeRegexTo(criteria, part, parameters.next() != null ? parameters.next().toString()
305+
: null); // what to return?
303306

304307
case NEVER:
305308
// intentional no-op

spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/AbstractPersonRepositoryIntegrationTests.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
* @author Christoph Strobl
6868
* @author Mark Paluch
6969
* @author Fırat KÜÇÜK
70+
* @author Edward Prentice
7071
*/
7172
@RunWith(SpringJUnit4ClassRunner.class)
7273
public abstract class AbstractPersonRepositoryIntegrationTests {
@@ -654,6 +655,14 @@ public void executesGeoPageQueryForWithPageRequestForJustOneElementEmptyPage() {
654655
assertThat(results.getAverageDistance().getMetric(), is((Metric) Metrics.KILOMETERS));
655656
}
656657

658+
@Test // DATAMONGO-1608
659+
public void findByFirstNameIgnoreCaseWithNull() {
660+
661+
List<Person> result = repository.findByFirstnameIgnoreCase(null);
662+
663+
assertThat(result.size(), is(nullValue()));
664+
}
665+
657666
@Test // DATAMONGO-770
658667
public void findByFirstNameIgnoreCase() {
659668

0 commit comments

Comments
 (0)