Skip to content

Commit 6fbbcab

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

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
@@ -55,6 +55,7 @@
5555
* @author Oliver Gierke
5656
* @author Thomas Darimont
5757
* @author Christoph Strobl
58+
* @author Edward Prentice
5859
*/
5960
class MongoQueryCreator extends AbstractQueryCreator<Query, Criteria> {
6061

@@ -299,7 +300,9 @@ private Criteria createLikeRegexCriteriaOrThrow(Part part, MongoPersistentProper
299300
criteria = criteria.not();
300301
}
301302

302-
return addAppropriateLikeRegexTo(criteria, part, parameters.next().toString());
303+
Object next = parameters.next();
304+
305+
return addAppropriateLikeRegexTo(criteria, part, next != null ? next.toString() : "");
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(0));
664+
}
665+
657666
@Test // DATAMONGO-770
658667
public void findByFirstNameIgnoreCase() {
659668

0 commit comments

Comments
 (0)