@@ -121,6 +121,17 @@ public void createsQueryToFindAllEntitiesByTwoStringAttributes() throws Exceptio
121
121
assertThat (bindableQuery .get ()).isEqualTo (expectedSql );
122
122
}
123
123
124
+ @ Test
125
+ public void createsQueryToFindAllEntitiesByOneOfTwoStringAttributes () throws Exception {
126
+ R2dbcQueryMethod queryMethod = getQueryMethod ("findByLastNameOrFirstName" , String .class , String .class );
127
+ PartTreeR2dbcQuery r2dbcQuery = new PartTreeR2dbcQuery (queryMethod , databaseClient , r2dbcConverter ,
128
+ dataAccessStrategy );
129
+ BindableQuery bindableQuery = r2dbcQuery .createQuery (getAccessor (queryMethod , new Object []{"Doe" , "John" }));
130
+ String expectedSql = "SELECT " + ALL_FIELDS + " FROM " + TABLE
131
+ + " WHERE " + TABLE + ".last_name = ? OR " + TABLE + ".first_name = ?" ;
132
+ assertThat (bindableQuery .get ()).isEqualTo (expectedSql );
133
+ }
134
+
124
135
private R2dbcQueryMethod getQueryMethod (String methodName , Class <?>... parameterTypes ) throws Exception {
125
136
Method method = UserRepository .class .getMethod (methodName , parameterTypes );
126
137
return new R2dbcQueryMethod (method , new DefaultRepositoryMetadata (UserRepository .class ),
@@ -136,6 +147,8 @@ private interface UserRepository extends Repository<User, Long> {
136
147
137
148
Flux <User > findByLastNameAndFirstName (String lastName , String firstName );
138
149
150
+ Flux <User > findByLastNameOrFirstName (String lastName , String firstName );
151
+
139
152
Mono <Boolean > existsByFirstName (String firstName );
140
153
}
141
154
0 commit comments