File tree Expand file tree Collapse file tree 2 files changed +29
-2
lines changed Expand file tree Collapse file tree 2 files changed +29
-2
lines changed Original file line number Diff line number Diff line change @@ -268,9 +268,10 @@ public function forceIndex($index): static
268
268
}
269
269
270
270
/**
271
+ * @param bool $toggle checking disabled when true, enabled when false
271
272
* @return $this
272
273
*/
273
- public function disableEmulatorNullFilteredIndexCheck (): static
274
+ public function disableEmulatorNullFilteredIndexCheck (bool $ toggle = true ): static
274
275
{
275
276
$ indexHint = $ this ->indexHint ;
276
277
@@ -279,7 +280,7 @@ public function disableEmulatorNullFilteredIndexCheck(): static
279
280
}
280
281
281
282
assert ($ indexHint instanceof IndexHint);
282
- $ indexHint ->disableEmulatorNullFilteredIndexCheck = true ;
283
+ $ indexHint ->disableEmulatorNullFilteredIndexCheck = $ toggle ;
283
284
284
285
return $ this ;
285
286
}
Original file line number Diff line number Diff line change @@ -474,6 +474,32 @@ public function test_disableEmulatorNullFilteredIndexCheck(): void
474
474
$ this ->assertSame ([], $ qb ->get ()->all ());
475
475
}
476
476
477
+ public function test_disableEmulatorNullFilteredIndexCheck_with_toggle_as_true (): void
478
+ {
479
+ $ conn = $ this ->getDefaultConnection ();
480
+ $ tableName = 'Test ' ;
481
+
482
+ $ qb = $ conn ->table ($ tableName )
483
+ ->forceIndex ('test_index_name ' )
484
+ ->disableEmulatorNullFilteredIndexCheck (true );
485
+
486
+ $ hint = '@{FORCE_INDEX=test_index_name,spanner_emulator.disable_query_null_filtered_index_check=true} ' ;
487
+ $ this ->assertSame ("select * from ` {$ tableName }` {$ hint }" , $ qb ->toSql ());
488
+ }
489
+
490
+ public function test_disableEmulatorNullFilteredIndexCheck_with_toggle_as_false (): void
491
+ {
492
+ $ conn = $ this ->getDefaultConnection ();
493
+ $ tableName = 'Test ' ;
494
+
495
+ $ qb = $ conn ->table ($ tableName )
496
+ ->forceIndex ('test_index_name ' )
497
+ ->disableEmulatorNullFilteredIndexCheck (false );
498
+
499
+ $ hint = '@{FORCE_INDEX=test_index_name} ' ;
500
+ $ this ->assertSame ("select * from ` {$ tableName }` {$ hint }" , $ qb ->toSql ());
501
+ }
502
+
477
503
public function test_disableEmulatorNullFilteredIndexCheck_without_calling_force_index (): void
478
504
{
479
505
$ this ->expectExceptionMessage ('Force index must be set before disabling null filter index check ' );
You can’t perform that action at this time.
0 commit comments