Skip to content

Commit

Permalink
fix deprecations for deprecated mysql server versions
Browse files Browse the repository at this point in the history
  • Loading branch information
dmaicher committed Mar 21, 2024
1 parent 7f209ad commit 1b42500
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 9 deletions.
5 changes: 4 additions & 1 deletion src/ConnectionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,10 @@ public function createConnection(array $params, ?Configuration $config = null, ?
$driver = $connection->getDriver();
/** @psalm-suppress InvalidScalarArgument Bogus error, StaticServerVersionProvider implements Doctrine\DBAL\ServerVersionProvider */
$platform = $driver->getDatabasePlatform(
...(class_exists(StaticServerVersionProvider::class) ? [new StaticServerVersionProvider($params['serverVersion'] ?? '')] : []),
...(class_exists(StaticServerVersionProvider::class)
? [new StaticServerVersionProvider($params['serverVersion'] ?? $params['primary']['serverVersion'] ?? '')]
: []
),
);

if (! isset($params['charset'])) {
Expand Down
4 changes: 2 additions & 2 deletions tests/ConnectionFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function testDefaultCharsetNonMySql(): void
public function testDefaultCharsetMySql(): void
{
$factory = new ConnectionFactory([]);
$params = ['driver' => 'pdo_mysql'];
$params = ['driver' => 'pdo_mysql', 'serverVersion' => '8.0.31'];

$connection = $factory->createConnection($params, $this->configuration);

Expand All @@ -53,7 +53,7 @@ public function testDefaultCharsetMySql(): void
public function testDefaultCollationMySql(): void
{
$factory = new ConnectionFactory([]);
$connection = $factory->createConnection(['driver' => 'pdo_mysql'], $this->configuration);
$connection = $factory->createConnection(['driver' => 'pdo_mysql', 'serverVersion' => '8.0.31'], $this->configuration);

$this->assertSame(
'utf8mb4_unicode_ci',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

<config>
<dbal default-connection="connection1">
<connection name="connection1" schema-filter="~^(?!t_)~" />
<connection name="connection2" />
<connection name="connection3" />
<connection name="connection1" schema-filter="~^(?!t_)~" server-version="8.0.31" />
<connection name="connection2" server-version="8.0.31" />
<connection name="connection3" server-version="8.0.31" />
</dbal>
</config>
</srv:container>
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<config>
<dbal default-connection="default">
<connection name="default" dbname="db" />
<connection name="default" dbname="db" server-version="8.0.31" />
</dbal>

<orm enable-lazy-ghost-objects="true">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@ doctrine:
connections:
connection1:
schema_filter: ~^(?!t_)~
connection2: []
connection3: []
server_version: 8.0.31
connection2:
server_version: 8.0.31
connection3:
server_version: 8.0.31
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ doctrine:
connections:
default:
dbname: db
server_version: 8.0.31

orm:
enable_lazy_ghost_objects: true
Expand Down

0 comments on commit 1b42500

Please sign in to comment.