Skip to content

[DoctrineBridge][Messenger] Add test cases for MariaDBPlatform #50574

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/Symfony/Bridge/Doctrine/Tests/Types/UlidTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Bridge\Doctrine\Tests\Types;

use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\MariaDBPlatform;
use Doctrine\DBAL\Platforms\MySQLPlatform;
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
use Doctrine\DBAL\Platforms\SqlitePlatform;
Expand Down Expand Up @@ -140,13 +141,15 @@ public function testGetGuidTypeDeclarationSQL(AbstractPlatform $platform, string
$this->assertEquals($expectedDeclaration, $this->type->getSqlDeclaration(['length' => 36], $platform));
}

public static function provideSqlDeclarations(): array
public static function provideSqlDeclarations(): \Generator
{
return [
[new PostgreSQLPlatform(), 'UUID'],
[new SqlitePlatform(), 'BLOB'],
[new MySQLPlatform(), 'BINARY(16)'],
];
yield [new PostgreSQLPlatform(), 'UUID'];
yield [new SqlitePlatform(), 'BLOB'];
yield [new MySQLPlatform(), 'BINARY(16)'];

if (class_exists(MariaDBPlatform::class)) {
yield [new MariaDBPlatform(), 'BINARY(16)'];
}
}

public function testRequiresSQLCommentHint()
Expand Down
15 changes: 9 additions & 6 deletions src/Symfony/Bridge/Doctrine/Tests/Types/UuidTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Bridge\Doctrine\Tests\Types;

use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\MariaDBPlatform;
use Doctrine\DBAL\Platforms\MySQLPlatform;
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
use Doctrine\DBAL\Platforms\SqlitePlatform;
Expand Down Expand Up @@ -152,13 +153,15 @@ public function testGetGuidTypeDeclarationSQL(AbstractPlatform $platform, string
$this->assertEquals($expectedDeclaration, $this->type->getSqlDeclaration(['length' => 36], $platform));
}

public static function provideSqlDeclarations(): array
public static function provideSqlDeclarations(): \Generator
{
return [
[new PostgreSQLPlatform(), 'UUID'],
[new SqlitePlatform(), 'BLOB'],
[new MySQLPlatform(), 'BINARY(16)'],
];
yield [new PostgreSQLPlatform(), 'UUID'];
yield [new SqlitePlatform(), 'BLOB'];
yield [new MySQLPlatform(), 'BINARY(16)'];

if (class_exists(MariaDBPlatform::class)) {
yield [new MariaDBPlatform(), 'BINARY(16)'];
}
}

public function testRequiresSQLCommentHint()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Doctrine\DBAL\Driver\ResultStatement;
use Doctrine\DBAL\Exception as DBALException;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\MariaDBPlatform;
use Doctrine\DBAL\Platforms\MySQL57Platform;
use Doctrine\DBAL\Platforms\OraclePlatform;
use Doctrine\DBAL\Platforms\SQLServer2012Platform;
Expand Down Expand Up @@ -394,6 +395,13 @@ public static function providePlatformSql(): iterable
'SELECT m.* FROM messenger_messages m WHERE (m.delivered_at is null OR m.delivered_at < ?) AND (m.available_at <= ?) AND (m.queue_name = ?) ORDER BY available_at ASC LIMIT 1 FOR UPDATE',
];

if (class_exists(MariaDBPlatform::class)) {
yield 'MariaDB' => [
new MariaDBPlatform(),
'SELECT m.* FROM messenger_messages m WHERE (m.delivered_at is null OR m.delivered_at < ?) AND (m.available_at <= ?) AND (m.queue_name = ?) ORDER BY available_at ASC LIMIT 1 FOR UPDATE',
];
}

yield 'SQL Server' => [
new SQLServer2012Platform(),
'SELECT m.* FROM messenger_messages m WITH (UPDLOCK, ROWLOCK) WHERE (m.delivered_at is null OR m.delivered_at < ?) AND (m.available_at <= ?) AND (m.queue_name = ?) ORDER BY available_at ASC OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY ',
Expand Down Expand Up @@ -479,6 +487,13 @@ public function provideFindAllSqlGeneratedByPlatform(): iterable
'SELECT m.* FROM messenger_messages m WHERE (m.delivered_at is null OR m.delivered_at < ?) AND (m.available_at <= ?) AND (m.queue_name = ?) LIMIT 50',
];

if (class_exists(MariaDBPlatform::class)) {
yield 'MariaDB' => [
new MariaDBPlatform(),
'SELECT m.* FROM messenger_messages m WHERE (m.delivered_at is null OR m.delivered_at < ?) AND (m.available_at <= ?) AND (m.queue_name = ?) LIMIT 50',
];
}

yield 'SQL Server' => [
new SQLServer2012Platform(),
'SELECT m.* FROM messenger_messages m WHERE (m.delivered_at is null OR m.delivered_at < ?) AND (m.available_at <= ?) AND (m.queue_name = ?) ORDER BY (SELECT 0) OFFSET 0 ROWS FETCH NEXT 50 ROWS ONLY',
Expand Down