Skip to content
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

Rework the logic of handling TEXT default value for Oracle MySQL #5348

Merged
merged 1 commit into from
Apr 6, 2022
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: 0 additions & 15 deletions src/Platforms/AbstractMySQLPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\TransactionIsolationLevel;
use Doctrine\DBAL\Types\BlobType;
use Doctrine\DBAL\Types\TextType;

use function array_merge;
use function array_unique;
Expand Down Expand Up @@ -271,19 +269,6 @@ protected function _getCreateTableSQL(string $name, array $columns, array $optio
return $sql;
}

/**
* {@inheritdoc}
*/
public function getDefaultValueDeclarationSQL(array $column): string
{
// Unset the default value if the given column definition does not allow default values.
if ($column['type'] instanceof TextType || $column['type'] instanceof BlobType) {
$column['default'] = null;
}

return parent::getDefaultValueDeclarationSQL($column);
}

/**
* Build SQL for table options
*
Expand Down
11 changes: 0 additions & 11 deletions src/Platforms/MariaDBPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,6 @@
*/
class MariaDBPlatform extends AbstractMySQLPlatform
{
/**
* {@inheritDoc}
*
* Hop over the {@see AbstractMySQLPlatform} implementation until 4.0.x
* where {@see MariaDBPlatform} no longer extends {@see MySQLPlatform}.
*/
public function getDefaultValueDeclarationSQL(array $column): string
{
return AbstractPlatform::getDefaultValueDeclarationSQL($column);
}

/**
* {@inheritdoc}
*
Expand Down
18 changes: 18 additions & 0 deletions src/Platforms/MySQLPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,31 @@
use Doctrine\DBAL\Platforms\Keywords\KeywordList;
use Doctrine\DBAL\Platforms\Keywords\MySQLKeywords;
use Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\Types\BlobType;
use Doctrine\DBAL\Types\TextType;

/**
* Provides the behavior, features and SQL dialect of the Oracle MySQL database platform
* of the oldest supported version.
*/
class MySQLPlatform extends AbstractMySQLPlatform
{
/**
* {@inheritDoc}
*
* Oracle MySQL does not support default values on TEXT/BLOB columns until 8.0.13.
*
* @link https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-13.html#mysqld-8-0-13-data-types
*/
public function getDefaultValueDeclarationSQL(array $column): string
{
if ($column['type'] instanceof TextType || $column['type'] instanceof BlobType) {
unset($column['default']);
}

return parent::getDefaultValueDeclarationSQL($column);
}

public function hasNativeJsonType(): bool
{
return true;
Expand Down