@@ -243,7 +243,6 @@ void detectsNamedInParameterBindings() {
243
243
assertThat (bindings ).hasSize (1 );
244
244
245
245
assertNamedBinding (InParameterBinding .class , "ids" , bindings .get (0 ));
246
-
247
246
}
248
247
249
248
@ Test // DATAJPA-461
@@ -276,7 +275,37 @@ void detectsPositionalInParameterBindings() {
276
275
assertThat (bindings ).hasSize (1 );
277
276
278
277
assertPositionalBinding (InParameterBinding .class , 1 , bindings .get (0 ));
278
+ }
279
+
280
+ @ Test // GH-3126
281
+ void allowsReuseOfParameterWithInAndRegularBinding () {
282
+
283
+ StringQuery query = new StringQuery (
284
+ "select u from User u where COALESCE(?1) is null OR u.id in ?1 OR COALESCE(?1) is null OR u.id in ?1" , true );
285
+
286
+ assertThat (query .hasParameterBindings ()).isTrue ();
287
+ assertThat (query .getQueryString ()).isEqualTo (
288
+ "select u from User u where COALESCE(?1) is null OR u.id in ?2 OR COALESCE(?1) is null OR u.id in ?2" );
289
+
290
+ List <ParameterBinding > bindings = query .getParameterBindings ();
291
+ assertThat (bindings ).hasSize (2 );
279
292
293
+ assertPositionalBinding (ParameterBinding .class , 1 , bindings .get (0 ));
294
+ assertPositionalBinding (InParameterBinding .class , 2 , bindings .get (1 ));
295
+
296
+ query = new StringQuery (
297
+ "select u from User u where COALESCE(:foo) is null OR u.id in :foo OR COALESCE(:foo) is null OR u.id in :foo" ,
298
+ true );
299
+
300
+ assertThat (query .hasParameterBindings ()).isTrue ();
301
+ assertThat (query .getQueryString ()).isEqualTo (
302
+ "select u from User u where COALESCE(:foo) is null OR u.id in :foo_1 OR COALESCE(:foo) is null OR u.id in :foo_1" );
303
+
304
+ bindings = query .getParameterBindings ();
305
+ assertThat (bindings ).hasSize (2 );
306
+
307
+ assertNamedBinding (ParameterBinding .class , "foo" , bindings .get (0 ));
308
+ assertNamedBinding (InParameterBinding .class , "foo_1" , bindings .get (1 ));
280
309
}
281
310
282
311
@ Test // DATAJPA-461
@@ -349,7 +378,6 @@ void detectsInBindingWithSpecialFrenchCharactersInParentheses() {
349
378
350
379
assertThat (bindings ).hasSize (1 );
351
380
assertNamedBinding (InParameterBinding .class , "abonnés" , bindings .get (0 ));
352
-
353
381
}
354
382
355
383
@ Test // DATAJPA-545
0 commit comments