diff --git a/tests/Query/BuilderTest.php b/tests/Query/BuilderTest.php index 2c57d69..f780fdc 100644 --- a/tests/Query/BuilderTest.php +++ b/tests/Query/BuilderTest.php @@ -22,12 +22,14 @@ use Colopl\Spanner\Schema\Blueprint; use Colopl\Spanner\Tests\TestCase; use Colopl\Spanner\TimestampBound\ExactStaleness; +use Google\Cloud\Core\Exception\BadRequestException; use Google\Cloud\Spanner\Bytes; use Google\Cloud\Spanner\Duration; use Illuminate\Database\QueryException; use Illuminate\Support\Carbon; use LogicException; +use Ramsey\Uuid\Uuid; use const Grpc\STATUS_ALREADY_EXISTS; class BuilderTest extends TestCase @@ -1083,4 +1085,22 @@ public function test_setRequestTimeoutSeconds(): void $this->expectExceptionMessageMatches('/DEADLINE_EXCEEDED/'); $query->get(); } + + public function test_whereIn_with_unnest_overflow_flag_turned_on(): void + { + $query = $this->getDefaultConnection()->table(self::TABLE_NAME_USER); + $query->whereIn('userId', array_map(Uuid::uuid4()->toString(...), range(1, 1000))); + $this->assertSame([], $query->get()); + } + + + public function test_whereIn_with_unnest_overflow_flag_turned_off(): void + { + $this->expectExceptionMessage('Number of parameters in query exceeds the maximum allowed limit of 950.'); + $this->expectException(QueryException::class); + + config()->set('database.connections.main.use_unnest_on_parameter_overflow', false); + $query = $this->getDefaultConnection()->table(self::TABLE_NAME_USER); + $query->whereIn('userId', array_map(Uuid::uuid4()->toString(...), range(1, 1000)))->get(); + } }