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

Stop using the deprecated json_array type internally #2782

Merged
merged 3 commits into from
Jul 22, 2017
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
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Platforms/DB2Platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,6 @@ public function supportsSavepoints()
*/
protected function getReservedKeywordsClass()
{
return 'Doctrine\DBAL\Platforms\Keywords\DB2Keywords';
return Keywords\DB2Keywords::class;
}
}
4 changes: 2 additions & 2 deletions lib/Doctrine/DBAL/Platforms/DrizzlePlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
namespace Doctrine\DBAL\Platforms;

use Doctrine\DBAL\Schema\Identifier;
use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\Types\BinaryType;

/**
Expand Down Expand Up @@ -314,7 +314,7 @@ public function getListDatabasesSQL()
*/
protected function getReservedKeywordsClass()
{
return 'Doctrine\DBAL\Platforms\Keywords\DrizzleKeywords';
return Keywords\DrizzleKeywords::class;
}

/**
Expand Down
5 changes: 3 additions & 2 deletions lib/Doctrine/DBAL/Platforms/MySQL57Platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

use Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\Types\Type;

/**
* Provides the behavior, features and SQL dialect of the MySQL 5.7 (5.7.9 GA) database platform.
Expand Down Expand Up @@ -79,7 +80,7 @@ protected function getRenameIndexSQL($oldIndexName, Index $index, $tableName)
*/
protected function getReservedKeywordsClass()
{
return 'Doctrine\DBAL\Platforms\Keywords\MySQL57Keywords';
return Keywords\MySQL57Keywords::class;
}

/**
Expand All @@ -89,6 +90,6 @@ protected function initializeDoctrineTypeMappings()
{
parent::initializeDoctrineTypeMappings();

$this->doctrineTypeMapping['json'] = 'json_array';
$this->doctrineTypeMapping['json'] = Type::JSON;
}
}
8 changes: 4 additions & 4 deletions lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@

namespace Doctrine\DBAL\Platforms;

use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Schema\Identifier;
use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\Types\BlobType;
use Doctrine\DBAL\Types\TextType;
use Doctrine\DBAL\Connection;

/**
* The MySqlPlatform provides the behavior, features and SQL dialect of the
Expand Down Expand Up @@ -712,7 +712,7 @@ private function getPreAlterTableAlterPrimaryKeySQL(TableDiff $diff, Index $inde
if (! $diff->fromTable->hasColumn($columnName)) {
continue;
}

$column = $diff->fromTable->getColumn($columnName);

if ($column->getAutoincrement() === true) {
Expand Down Expand Up @@ -1070,7 +1070,7 @@ public function getBinaryMaxLength()
*/
protected function getReservedKeywordsClass()
{
return 'Doctrine\DBAL\Platforms\Keywords\MySQLKeywords';
return Keywords\MySQLKeywords::class;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/DBAL/Platforms/OraclePlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@

namespace Doctrine\DBAL\Platforms;

use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Schema\ForeignKeyConstraint;
use Doctrine\DBAL\Schema\Identifier;
use Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\Schema\Sequence;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Types\BinaryType;

/**
Expand Down Expand Up @@ -1156,7 +1156,7 @@ public function releaseSavePoint($savepoint)
*/
protected function getReservedKeywordsClass()
{
return 'Doctrine\DBAL\Platforms\Keywords\OracleKeywords';
return Keywords\OracleKeywords::class;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Platforms/PostgreSQL91Platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function supportsColumnCollation()
*/
protected function getReservedKeywordsClass()
{
return 'Doctrine\DBAL\Platforms\Keywords\PostgreSQL91Keywords';
return Keywords\PostgreSQL91Keywords::class;
}

/**
Expand Down
7 changes: 5 additions & 2 deletions lib/Doctrine/DBAL/Platforms/PostgreSQL92Platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

namespace Doctrine\DBAL\Platforms;

use Doctrine\DBAL\Types\Type;

/**
* Provides the behavior, features and SQL dialect of the PostgreSQL 9.2 database platform.
*
Expand Down Expand Up @@ -61,7 +63,7 @@ public function hasNativeJsonType()
*/
protected function getReservedKeywordsClass()
{
return 'Doctrine\DBAL\Platforms\Keywords\PostgreSQL92Keywords';
return Keywords\PostgreSQL92Keywords::class;
}

/**
Expand All @@ -70,7 +72,8 @@ protected function getReservedKeywordsClass()
protected function initializeDoctrineTypeMappings()
{
parent::initializeDoctrineTypeMappings();
$this->doctrineTypeMapping['json'] = 'json_array';

$this->doctrineTypeMapping['json'] = Type::JSON;
}

/**
Expand Down
7 changes: 5 additions & 2 deletions lib/Doctrine/DBAL/Platforms/PostgreSQL94Platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

namespace Doctrine\DBAL\Platforms;

use Doctrine\DBAL\Types\Type;

/**
* Provides the behavior, features and SQL dialect of the PostgreSQL 9.4 database platform.
*
Expand All @@ -45,7 +47,7 @@ public function getJsonTypeDeclarationSQL(array $field)
*/
protected function getReservedKeywordsClass()
{
return 'Doctrine\DBAL\Platforms\Keywords\PostgreSQL94Keywords';
return Keywords\PostgreSQL94Keywords::class;
}

/**
Expand All @@ -54,6 +56,7 @@ protected function getReservedKeywordsClass()
protected function initializeDoctrineTypeMappings()
{
parent::initializeDoctrineTypeMappings();
$this->doctrineTypeMapping['jsonb'] = 'json_array';

$this->doctrineTypeMapping['jsonb'] = Type::JSON;
}
}
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -1166,7 +1166,7 @@ public function getBinaryDefaultLength()
*/
protected function getReservedKeywordsClass()
{
return 'Doctrine\DBAL\Platforms\Keywords\PostgreSQLKeywords';
return Keywords\PostgreSQLKeywords::class;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Platforms/SQLAnywhere11Platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ public function getRegexpExpression()
*/
protected function getReservedKeywordsClass()
{
return 'Doctrine\DBAL\Platforms\Keywords\SQLAnywhere11Keywords';
return Keywords\SQLAnywhere11Keywords::class;
}
}
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Platforms/SQLAnywhere12Platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ protected function getAdvancedIndexOptionsSQL(Index $index)
*/
protected function getReservedKeywordsClass()
{
return 'Doctrine\DBAL\Platforms\Keywords\SQLAnywhere12Keywords';
return Keywords\SQLAnywhere12Keywords::class;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Platforms/SQLAnywhere16Platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ protected function getAdvancedIndexOptionsSQL(Index $index)
*/
protected function getReservedKeywordsClass()
{
return 'Doctrine\DBAL\Platforms\Keywords\SQLAnywhere16Keywords';
return Keywords\SQLAnywhere16Keywords::class;
}
}
4 changes: 2 additions & 2 deletions lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
use Doctrine\DBAL\Schema\ColumnDiff;
use Doctrine\DBAL\Schema\Constraint;
use Doctrine\DBAL\Schema\ForeignKeyConstraint;
use Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\Schema\Identifier;
use Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\TableDiff;

Expand Down Expand Up @@ -1429,7 +1429,7 @@ protected function getRenameIndexSQL($oldIndexName, Index $index, $tableName)
*/
protected function getReservedKeywordsClass()
{
return 'Doctrine\DBAL\Platforms\Keywords\SQLAnywhereKeywords';
return Keywords\SQLAnywhereKeywords::class;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Platforms/SQLServer2005Platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ public function getClobTypeDeclarationSQL(array $field)
*/
protected function getReservedKeywordsClass()
{
return 'Doctrine\DBAL\Platforms\Keywords\SQLServer2005Keywords';
return Keywords\SQLServer2005Keywords::class;
}
}
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Platforms/SQLServer2008Platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,6 @@ protected function initializeDoctrineTypeMappings()
*/
protected function getReservedKeywordsClass()
{
return 'Doctrine\DBAL\Platforms\Keywords\SQLServer2008Keywords';
return Keywords\SQLServer2008Keywords::class;
}
}
4 changes: 2 additions & 2 deletions lib/Doctrine/DBAL/Platforms/SQLServer2012Platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function supportsSequences()
*/
protected function getReservedKeywordsClass()
{
return 'Doctrine\DBAL\Platforms\Keywords\SQLServer2012Keywords';
return Keywords\SQLServer2012Keywords::class;
}

/**
Expand All @@ -122,7 +122,7 @@ protected function doModifyLimitQuery($query, $limit, $offset = null)
if ($matchesCount > 0) {
$orderByPos = $matches[0][($matchesCount - 1)][1];
}

if ($orderByPos === false
|| substr_count($query, "(", $orderByPos) - substr_count($query, ")", $orderByPos)
) {
Expand Down
6 changes: 3 additions & 3 deletions lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
use Doctrine\DBAL\LockMode;
use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\ColumnDiff;
use Doctrine\DBAL\Schema\Identifier;
use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\Schema\ForeignKeyConstraint;
use Doctrine\DBAL\Schema\Identifier;
use Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\TableDiff;

/**
* The SQLServerPlatform provides the behavior, features and SQL dialect of the
Expand Down Expand Up @@ -1512,7 +1512,7 @@ public function getForUpdateSQL()
*/
protected function getReservedKeywordsClass()
{
return 'Doctrine\DBAL\Platforms\Keywords\SQLServerKeywords';
return Keywords\SQLServerKeywords::class;
}

/**
Expand Down
10 changes: 5 additions & 5 deletions lib/Doctrine/DBAL/Platforms/SqlitePlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@

use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\Constraint;
use Doctrine\DBAL\Schema\ForeignKeyConstraint;
use Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\Schema\Identifier;
use Doctrine\DBAL\Schema\Constraint;
use Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\TableDiff;

/**
* The SqlitePlatform class describes the specifics and dialects of the SQLite
Expand Down Expand Up @@ -633,7 +633,7 @@ protected function initializeDoctrineTypeMappings()
*/
protected function getReservedKeywordsClass()
{
return 'Doctrine\DBAL\Platforms\Keywords\SQLiteKeywords';
return Keywords\SQLiteKeywords::class;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ protected function _getPortableTableColumnDefinition($tableColumn)
$column->setPlatformOption('collation', $tableColumn['collation']);
}

if ($column->getType()->getName() === 'json_array') {
if (in_array($column->getType()->getName(), [Type::JSON_ARRAY, Type::JSON], true)) {
$column->setPlatformOption('jsonb', $jsonb);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function testGetSearchPath()
$params = $this->_conn->getParams();

$paths = $this->_sm->getSchemaSearchPaths();
$this->assertEquals(array($params['user'], 'public'), $paths);
$this->assertEquals([$params['user'], 'public'], $paths);
}

/**
Expand All @@ -40,7 +40,7 @@ public function testGetSchemaNames()

$this->assertInternalType('array', $names);
$this->assertTrue(count($names) > 0);
$this->assertTrue(in_array('public', $names), "The public schema should be found.");
$this->assertContains('public', $names, 'The public schema should be found.');
}

/**
Expand Down Expand Up @@ -366,22 +366,33 @@ public function testPartialIndexes()
$this->assertSame('(id IS NULL)', $onlineTable->getIndex('simple_partial_index')->getOption('where'));
}

public function testJsonbColumn()
/**
* @dataProvider jsonbColumnTypeProvider
*/
public function testJsonbColumn(string $type): void
{
if (!$this->_sm->getDatabasePlatform() instanceof PostgreSQL94Platform) {
$this->markTestSkipped("Requires PostgresSQL 9.4+");
return;
}

$table = new Schema\Table('test_jsonb');
$table->addColumn('foo', 'json_array')->setPlatformOption('jsonb', true);
$table->addColumn('foo', $type)->setPlatformOption('jsonb', true);
$this->_sm->dropAndCreateTable($table);

/** @var Schema\Column[] $columns */
$columns = $this->_sm->listTableColumns('test_jsonb');

$this->assertEquals('json_array', $columns['foo']->getType()->getName());
$this->assertEquals(true, $columns['foo']->getPlatformOption('jsonb'));
$this->assertSame(TYPE::JSON, $columns['foo']->getType()->getName());
$this->assertTrue(true, $columns['foo']->getPlatformOption('jsonb'));
}

public function jsonbColumnTypeProvider(): array
{
return [
[Type::JSON],
[Type::JSON_ARRAY],
];
}

/**
Expand Down
3 changes: 2 additions & 1 deletion tests/Doctrine/Tests/DBAL/Platforms/MySQL57PlatformTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Doctrine\Tests\DBAL\Platforms;

use Doctrine\DBAL\Platforms\MySQL57Platform;
use Doctrine\DBAL\Types\Type;

class MySQL57PlatformTest extends AbstractMySQLPlatformTestCase
{
Expand All @@ -27,7 +28,7 @@ public function testReturnsJsonTypeDeclarationSQL()
public function testInitializesJsonTypeMapping()
{
$this->assertTrue($this->_platform->hasDoctrineTypeMappingFor('json'));
$this->assertSame('json_array', $this->_platform->getDoctrineTypeMapping('json'));
$this->assertSame(Type::JSON, $this->_platform->getDoctrineTypeMapping('json'));
}

/**
Expand Down
Loading