Skip to content

Commit 7c9d192

Browse files
committed
add MariaDB support
1 parent a3216a4 commit 7c9d192

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

src/Sql/MySQL.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class MySQL extends SqlBase
1515
* @param array<string, mixed> $config The config array from the connection object
1616
* @param \Cake\Database\Driver\Mysql $driver The current mysql driver instance
1717
*/
18-
public function __construct(array $config, MysqlDriver $driver)
18+
public function __construct(array $config, protected MysqlDriver $driver)
1919
{
2020
parent::__construct($config);
2121

@@ -42,8 +42,14 @@ public function dump(): string
4242
'--host=' . ($this->config['host'] ?? 'localhost'),
4343
'--databases',
4444
$this->config['database'],
45-
'--no-create-db',
4645
];
46+
47+
if ($this->driver->isMariadb()) {
48+
$command[] = '--skip-create-options';
49+
} else {
50+
$command[] = '--no-create-db';
51+
}
52+
4753
if ($this->isDataOnly()) {
4854
$command[] = '--no-create-info';
4955
}

tests/TestCase/Command/DumpSqlCommandTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public function testCommand(): void
4747
$this->assertOutputContains('INSERT INTO posts VALUES(');
4848
} elseif ($this->isDBType(Mysql::class)) {
4949
var_dump($this->_out->messages());
50+
var_dump($this->_err->messages());
5051
$this->assertOutputContains('CREATE TABLE `posts` (');
5152
$this->assertOutputContains('INSERT INTO `posts` VALUES (');
5253
} elseif ($this->isDBType(Postgres::class)) {

0 commit comments

Comments
 (0)