@@ -251,7 +251,7 @@ public function testWhereExpression(): void
251
251
* @param array{string, array<mixed>} $exprLeft
252
252
* @param array{string, array<mixed>} $exprRight
253
253
*/
254
- public function testWhereNumericCompare (array $ exprLeft , string $ operator , array $ exprRight , bool $ expectPostgresqlTypeMismatchException = false , bool $ expectMssqlTypeMismatchException = false , bool $ expectSqliteWrongAffinity = false ): void
254
+ public function testWhereNumericCompare (array $ exprLeft , string $ operator , array $ exprRight , bool $ expectPostgresqlTypeMismatchException = false , bool $ expectMssqlTypeMismatchException = false ): void
255
255
{
256
256
if ($ this ->getDatabasePlatform () instanceof OraclePlatform) {
257
257
$ exprLeft [0 ] = preg_replace ('~\d+[eE][\-+]?\d++~ ' , '$0d ' , $ exprLeft [0 ]);
@@ -272,14 +272,27 @@ public function testWhereNumericCompare(array $exprLeft, string $operator, array
272
272
}
273
273
$ queryHaving ->having ($ this ->e (...$ exprLeft ), $ operator , $ this ->e (...$ exprRight ));
274
274
275
- $ queryWhere2 = $ this ->q ()->field ($ this ->e ('1 ' ), 'v ' );
276
- $ queryWhere2 ->table ($ this ->q ()->field ($ this ->e (...$ exprLeft ), 'a ' )->field ($ this ->e (...$ exprRight ), 'b ' ), 't ' );
277
- $ queryWhere2 ->where ('a ' , $ operator , $ this ->e ('{} ' , ['b ' ]));
275
+ $ queryWhereSub = $ this ->q ()->field ($ this ->e ('1 ' ), 'v ' );
276
+ $ queryWhereSub ->table ($ this ->q ()->field ($ this ->e (...$ exprLeft ), 'a ' )->field ($ this ->e (...$ exprRight ), 'b ' ), 't ' );
277
+ $ queryWhereSub ->where ('a ' , $ operator , $ this ->e ('{} ' , ['b ' ]));
278
+
279
+ $ queryWhereIn = $ this ->q ()->field ($ this ->e ('1 ' ), 'v ' );
280
+ if ($ this ->getDatabasePlatform () instanceof MySQLPlatform) {
281
+ $ queryWhereIn ->table ('(select 1) ' , 'dual ' ); // needed for MySQL 5.x when WHERE or HAVING is specified
282
+ }
283
+ if ($ operator === '= ' || $ operator === '!= ' ) {
284
+ $ queryWhereIn ->where (
285
+ $ this ->e (...$ exprLeft ),
286
+ $ operator === '!= ' ? 'not in ' : 'in ' ,
287
+ [$ this ->e (...$ exprRight ), $ this ->e (...$ exprRight )]
288
+ );
289
+ }
278
290
279
291
$ queryAll = $ this ->q ()
280
292
->field ($ queryWhere , 'where ' )
281
293
->field ($ queryHaving , 'having ' )
282
- ->field ($ queryWhere2 , 'where2 ' );
294
+ ->field ($ queryWhereSub , 'where_sub ' )
295
+ ->field ($ queryWhereIn , 'where_in ' );
283
296
284
297
if (($ expectPostgresqlTypeMismatchException && $ this ->getDatabasePlatform () instanceof PostgreSQLPlatform) || ($ expectMssqlTypeMismatchException && $ this ->getDatabasePlatform () instanceof SQLServerPlatform)) {
285
298
$ this ->expectException (ExecuteException::class);
@@ -299,9 +312,7 @@ public function testWhereNumericCompare(array $exprLeft, string $operator, array
299
312
}
300
313
301
314
self ::assertSame (
302
- $ expectSqliteWrongAffinity && $ this ->getDatabasePlatform () instanceof SQLitePlatform
303
- ? [['where ' => null , 'having ' => null , 'where2 ' => null ]]
304
- : [['where ' => '1 ' , 'having ' => '1 ' , 'where2 ' => '1 ' ]],
315
+ [['where ' => '1 ' , 'having ' => '1 ' , 'where_sub ' => '1 ' , 'where_in ' => '1 ' ]],
305
316
$ rows
306
317
);
307
318
}
@@ -361,11 +372,11 @@ public function provideWhereNumericCompareCases(): iterable
361
372
yield [['[] ' , [false ]], '!= ' , ['[] ' , [true ]]];
362
373
yield [['[] ' , [false ]], '< ' , ['[] ' , [true ]]];
363
374
364
- yield [['4 ' ], '= ' , ['[] ' , ['04 ' ]], true , false , true ];
375
+ yield [['4 ' ], '= ' , ['[] ' , ['04 ' ]], true ];
365
376
yield [['\'04 \'' ], '= ' , ['[] ' , [4 ]], true ];
366
377
yield [['4 ' ], '= ' , ['[] ' , [4.0 ]]];
367
- yield [['4 ' ], '= ' , ['[] ' , ['4.0 ' ]], true , true , true ];
368
- yield [['2.5 ' ], '= ' , ['[] ' , ['02.50 ' ]], true , false , true ];
378
+ yield [['4 ' ], '= ' , ['[] ' , ['4.0 ' ]], true , true ];
379
+ yield [['2.5 ' ], '= ' , ['[] ' , ['02.50 ' ]], true ];
369
380
yield [['0 ' ], '= ' , ['[] ' , [false ]], true ];
370
381
yield [['0 ' ], '!= ' , ['[] ' , [true ]], true ];
371
382
yield [['1 ' ], '= ' , ['[] ' , [true ]], true ];
@@ -374,11 +385,11 @@ public function provideWhereNumericCompareCases(): iterable
374
385
yield [['2 + 2 ' ], '= ' , ['[] ' , [4 ]]];
375
386
yield [['2 + 2 ' ], '= ' , ['[] + [] ' , [1 , 3 ]]];
376
387
yield [['[] + [] ' , [-1 , 5 ]], '= ' , ['[] + [] ' , [1 , 3 ]]];
377
- yield [['2 + 2 ' ], '= ' , ['[] ' , ['4 ' ]], true , false , true ];
388
+ yield [['2 + 2 ' ], '= ' , ['[] ' , ['4 ' ]], true ];
378
389
yield [['2 + 2.5 ' ], '= ' , ['[] ' , [4.5 ]]];
379
390
yield [['2 + 2.5 ' ], '= ' , ['[] + [] ' , [1.5 , 3.0 ]]];
380
391
yield [['[] + [] ' , [-1.5 , 6.0 ]], '= ' , ['[] + [] ' , [1.5 , 3.0 ]]];
381
- yield [['2 + 2.5 ' ], '= ' , ['[] ' , ['4.5 ' ]], true , false , true ];
392
+ yield [['2 + 2.5 ' ], '= ' , ['[] ' , ['4.5 ' ]], true ];
382
393
}
383
394
384
395
public function testGroupConcat (): void
0 commit comments