Skip to content

Commit

Permalink
Move getJsonTypeDeclarationSQL() to AbstractMySQLPlatform (doctri…
Browse files Browse the repository at this point in the history
…ne#6216)

|      Q       |   A
|------------- | -----------
| Type         | improvement
| Fixed issues | N/A

#### Summary

Both MySQL dialects support the `JSON` column type, so let's move this
method up to `AbstractMySQLPlatform`.
  • Loading branch information
derrabus committed Nov 6, 2023
1 parent 6b97ee3 commit 8134e7c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 25 deletions.
8 changes: 8 additions & 0 deletions src/Platforms/AbstractMySQLPlatform.php
Expand Up @@ -119,6 +119,14 @@ public function getListViewsSQL(string $database): string
return 'SELECT * FROM information_schema.VIEWS WHERE TABLE_SCHEMA = ' . $this->quoteStringLiteral($database);
}

/**
* {@inheritDoc}
*/
public function getJsonTypeDeclarationSQL(array $column): string
{
return 'JSON';
}

/**
* Gets the SQL snippet used to declare a CLOB column type.
* TINYTEXT : 2 ^ 8 - 1 = 255
Expand Down
17 changes: 0 additions & 17 deletions src/Platforms/MariaDBPlatform.php
Expand Up @@ -20,19 +20,6 @@
*/
class MariaDBPlatform extends AbstractMySQLPlatform
{
/**
* Use JSON rather than LONGTEXT for json columns. Since it is not a true native type, do not override
* hasNativeJsonType() so the DC2Type comment will still be set.
*
* @link https://mariadb.com/kb/en/library/json-data-type/
*
* {@inheritDoc}
*/
public function getJsonTypeDeclarationSQL(array $column): string
{
return 'JSON';
}

/**
* Generate SQL snippets to reverse the aliasing of JSON to LONGTEXT.
*
Expand All @@ -46,10 +33,6 @@ public function getJsonTypeDeclarationSQL(array $column): string
*/
public function getColumnTypeSQLSnippets(string $tableAlias = 'c'): array
{
if ($this->getJsonTypeDeclarationSQL([]) !== 'JSON') {
return parent::getColumnTypeSQLSnippets($tableAlias);
}

$columnTypeSQL = <<<SQL
IF(
x.CHECK_CLAUSE IS NOT NULL AND $tableAlias.COLUMN_TYPE = 'longtext',
Expand Down
8 changes: 0 additions & 8 deletions src/Platforms/MySQLPlatform.php
Expand Up @@ -34,14 +34,6 @@ public function getDefaultValueDeclarationSQL(array $column): string
return parent::getDefaultValueDeclarationSQL($column);
}

/**
* {@inheritDoc}
*/
public function getJsonTypeDeclarationSQL(array $column): string
{
return 'JSON';
}

/**
* {@inheritDoc}
*/
Expand Down

0 comments on commit 8134e7c

Please sign in to comment.