Skip to content

Commit cfdf5b5

Browse files
authored
Merge pull request #6942 from morozov/remove-jsonb-and-version-options
Remove "jsonb" and "version" options
2 parents a5a3367 + cde3126 commit cfdf5b5

14 files changed

+35
-154
lines changed

UPGRADE.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,16 @@ awareness about deprecated code.
88

99
# Upgrade to 5.0
1010

11-
## BC BREAK: Classes marked as read-only:
11+
## BC BREAK: Removed support for the `version` column platform option
12+
13+
The `version` column platform option is no longer supported.
14+
15+
## BC BREAK: Removed support for the `jsonb` column platform option
16+
17+
The `jsonb` column platform option is no longer supported. `JSONB` columns on PostgreSQL are now introspected
18+
as columns of type `JSONB`, not as columns of type `JSON` with `jsonb` option set.
19+
20+
## BC BREAK: Classes marked as read-only
1221

1322
The following classes have been marked as read-only:
1423

@@ -51,7 +60,7 @@ The following classes have been marked as read-only:
5160
- `Doctrine\DBAL\Tools\Console\ConnectionProvider\SingleConnectionProvider`
5261
- `Doctrine\DBAL\Tools\DsnParser`
5362

54-
## BC BREAK: Classes marked as final:
63+
## BC BREAK: Classes marked as final
5564

5665
The following classes have been marked as final:
5766

src/Platforms/AbstractMySQLPlatform.php

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use Doctrine\DBAL\Schema\TableDiff;
1818
use Doctrine\DBAL\TransactionIsolationLevel;
1919
use Doctrine\DBAL\Types\Types;
20-
use Doctrine\Deprecations\Deprecation;
2120

2221
use function array_map;
2322
use function array_merge;
@@ -129,14 +128,6 @@ public function getListViewsSQL(string $database): string
129128
*/
130129
public function getJsonTypeDeclarationSQL(array $column): string
131130
{
132-
if (! empty($column['jsonb'])) {
133-
Deprecation::trigger(
134-
'doctrine/dbal',
135-
'https://github.com/doctrine/dbal/pull/6939',
136-
'The "jsonb" column platform option is deprecated. Use the "JSONB" type instead.',
137-
);
138-
}
139-
140131
return 'JSON';
141132
}
142133

@@ -175,16 +166,6 @@ public function getClobTypeDeclarationSQL(array $column): string
175166
*/
176167
public function getDateTimeTypeDeclarationSQL(array $column): string
177168
{
178-
if (isset($column['version']) && $column['version'] === true) {
179-
Deprecation::trigger(
180-
'doctrine/dbal',
181-
'https://github.com/doctrine/dbal/pull/6940',
182-
'The "version" column platform option is deprecated.',
183-
);
184-
185-
return 'TIMESTAMP';
186-
}
187-
188169
return 'DATETIME';
189170
}
190171

src/Platforms/AbstractPlatform.php

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
use Doctrine\DBAL\Types\Exception\TypeNotFound;
4848
use Doctrine\DBAL\Types\Exception\TypesException;
4949
use Doctrine\DBAL\Types\Type;
50-
use Doctrine\Deprecations\Deprecation;
5150

5251
use function addcslashes;
5352
use function array_map;
@@ -256,14 +255,6 @@ public function getGuidTypeDeclarationSQL(array $column): string
256255
*/
257256
public function getJsonTypeDeclarationSQL(array $column): string
258257
{
259-
if (! empty($column['jsonb'])) {
260-
Deprecation::trigger(
261-
'doctrine/dbal',
262-
'https://github.com/doctrine/dbal/pull/6939',
263-
'The "jsonb" column platform option is deprecated. Use the "JSONB" type instead.',
264-
);
265-
}
266-
267258
return $this->getClobTypeDeclarationSQL($column);
268259
}
269260

@@ -879,7 +870,7 @@ private function buildCreateTableSQL(Table $table, bool $createForeignKeys): arr
879870
$columns = [];
880871

881872
foreach ($table->getColumns() as $column) {
882-
$columns[] = $this->columnToArray($column);
873+
$columns[] = $column->toArray();
883874
}
884875

885876
$sql = $this->_getCreateTableSQL($tableName, $columns, $parameters);
@@ -2140,17 +2131,6 @@ final public function escapeStringForLike(string $inputString, string $escapeCha
21402131
return $sql;
21412132
}
21422133

2143-
/**
2144-
* @return ColumnProperties An associative array with the name of the properties of the column being declared as
2145-
* array keys.
2146-
*/
2147-
private function columnToArray(Column $column): array
2148-
{
2149-
return array_merge($column->toArray(), [
2150-
'version' => $column->hasPlatformOption('version') ? $column->getPlatformOption('version') : false,
2151-
]);
2152-
}
2153-
21542134
/** @internal */
21552135
public function createSQLParser(): Parser
21562136
{
@@ -2167,8 +2147,8 @@ protected function getLikeWildcardCharacters(): string
21672147
*/
21682148
public function columnsEqual(Column $column1, Column $column2): bool
21692149
{
2170-
$column1Array = $this->columnToArray($column1);
2171-
$column2Array = $this->columnToArray($column2);
2150+
$column1Array = $column1->toArray();
2151+
$column2Array = $column2->toArray();
21722152

21732153
$name = UnqualifiedName::unquoted('dummy');
21742154

src/Platforms/DB2Platform.php

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818
use Doctrine\DBAL\SQL\Builder\DefaultSelectSQLBuilder;
1919
use Doctrine\DBAL\SQL\Builder\SelectSQLBuilder;
2020
use Doctrine\DBAL\TransactionIsolationLevel;
21-
use Doctrine\DBAL\Types\DateTimeType;
2221
use Doctrine\DBAL\Types\Types;
23-
use Doctrine\Deprecations\Deprecation;
2422

2523
use function array_merge;
2624
use function count;
@@ -174,16 +172,6 @@ public function getDateDiffExpression(string $date1, string $date2): string
174172
*/
175173
public function getDateTimeTypeDeclarationSQL(array $column): string
176174
{
177-
if (isset($column['version']) && $column['version'] === true) {
178-
Deprecation::trigger(
179-
'doctrine/dbal',
180-
'https://github.com/doctrine/dbal/pull/6940',
181-
'The "version" column platform option is deprecated.',
182-
);
183-
184-
return 'TIMESTAMP(0) WITH DEFAULT';
185-
}
186-
187175
return 'TIMESTAMP(0)';
188176
}
189177

@@ -498,18 +486,6 @@ protected function getDefaultValueDeclarationSQL(array $column): string
498486
return '';
499487
}
500488

501-
if (isset($column['version']) && $column['version'] === true) {
502-
Deprecation::trigger(
503-
'doctrine/dbal',
504-
'https://github.com/doctrine/dbal/pull/6940',
505-
'The "version" column platform option is deprecated.',
506-
);
507-
508-
if ($column['type'] instanceof DateTimeType) {
509-
$column['default'] = '1';
510-
}
511-
}
512-
513489
return parent::getDefaultValueDeclarationSQL($column);
514490
}
515491

src/Platforms/PostgreSQLPlatform.php

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
use Doctrine\DBAL\Schema\TableDiff;
2020
use Doctrine\DBAL\TransactionIsolationLevel;
2121
use Doctrine\DBAL\Types\Types;
22-
use Doctrine\Deprecations\Deprecation;
2322
use UnexpectedValueException;
2423

2524
use function array_merge;
@@ -262,7 +261,6 @@ public function getAlterTableSQL(TableDiff $diff): array
262261
|| $columnDiff->hasScaleChanged()
263262
|| $columnDiff->hasFixedChanged()
264263
|| $columnDiff->hasLengthChanged()
265-
|| $columnDiff->hasPlatformOptionsChanged()
266264
) {
267265
$type = $newColumn->getType();
268266

@@ -723,7 +721,7 @@ protected function initializeDoctrineTypeMappings(): void
723721
'integer' => Types::INTEGER,
724722
'interval' => Types::STRING,
725723
'json' => Types::JSON,
726-
'jsonb' => Types::JSON,
724+
'jsonb' => Types::JSONB,
727725
'money' => Types::DECIMAL,
728726
'numeric' => Types::DECIMAL,
729727
'serial' => Types::INTEGER,
@@ -773,16 +771,6 @@ protected function supportsColumnCollation(): bool
773771
*/
774772
public function getJsonTypeDeclarationSQL(array $column): string
775773
{
776-
if (! empty($column['jsonb'])) {
777-
Deprecation::trigger(
778-
'doctrine/dbal',
779-
'https://github.com/doctrine/dbal/pull/6939',
780-
'The "jsonb" column platform option is deprecated. Use the "JSONB" type instead.',
781-
);
782-
783-
return 'JSONB';
784-
}
785-
786774
return 'JSON';
787775
}
788776

src/Schema/Column.php

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
use Doctrine\DBAL\Schema\Name\Parsers;
1010
use Doctrine\DBAL\Schema\Name\UnqualifiedName;
1111
use Doctrine\DBAL\Types\Type;
12-
use Doctrine\Deprecations\Deprecation;
1312

1413
use function array_merge;
1514
use function method_exists;
@@ -33,8 +32,6 @@
3332
* charset?: ?string,
3433
* collation?: ?string,
3534
* default_constraint_name?: string,
36-
* jsonb?: bool,
37-
* version?: bool,
3835
* }
3936
*/
4037
class Column extends AbstractNamedObject
@@ -160,14 +157,6 @@ public function setDefault(mixed $default): self
160157
/** @param PlatformOptions $platformOptions */
161158
public function setPlatformOptions(array $platformOptions): self
162159
{
163-
if (isset($platformOptions['jsonb']) && $platformOptions['jsonb']) {
164-
Deprecation::triggerIfCalledFromOutside(
165-
'doctrine/dbal',
166-
'https://github.com/doctrine/dbal/pull/6939',
167-
'The "jsonb" column platform option is deprecated. Use the "JSONB" type instead.',
168-
);
169-
}
170-
171160
$this->_platformOptions = $platformOptions;
172161

173162
return $this;
@@ -176,14 +165,6 @@ public function setPlatformOptions(array $platformOptions): self
176165
/** @param key-of<PlatformOptions> $name */
177166
public function setPlatformOption(string $name, mixed $value): self
178167
{
179-
if ($name === 'jsonb' && (bool) $value === true) {
180-
Deprecation::triggerIfCalledFromOutside(
181-
'doctrine/dbal',
182-
'https://github.com/doctrine/dbal/pull/6939',
183-
'The "jsonb" column platform option is deprecated. Use the "JSONB" type instead.',
184-
);
185-
}
186-
187168
$this->_platformOptions[$name] = $value;
188169

189170
return $this;

src/Schema/PostgreSQLSchemaManager.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use Doctrine\DBAL\Schema\ForeignKeyConstraint\ReferentialAction;
1111
use Doctrine\DBAL\Schema\Index\IndexType;
1212
use Doctrine\DBAL\Schema\Name\OptionallyQualifiedName;
13-
use Doctrine\DBAL\Types\JsonType;
1413
use Doctrine\DBAL\Types\Type;
1514

1615
use function array_change_key_case;
@@ -188,7 +187,6 @@ protected function _getPortableTableColumnDefinition(array $tableColumn): Column
188187
$precision = null;
189188
$scale = 0;
190189
$fixed = false;
191-
$jsonb = false;
192190

193191
$dbType = $tableColumn['typname'];
194192
if (
@@ -231,8 +229,6 @@ protected function _getPortableTableColumnDefinition(array $tableColumn): Column
231229

232230
if ($dbType === 'bpchar') {
233231
$fixed = true;
234-
} elseif ($dbType === 'jsonb') {
235-
$jsonb = true;
236232
}
237233

238234
$options = [
@@ -255,10 +251,6 @@ protected function _getPortableTableColumnDefinition(array $tableColumn): Column
255251
$column->setPlatformOption('collation', $tableColumn['collation']);
256252
}
257253

258-
if ($column->getType() instanceof JsonType) {
259-
$column->setPlatformOption('jsonb', $jsonb);
260-
}
261-
262254
return $column;
263255
}
264256

tests/Functional/Schema/PostgreSQL/ComparatorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,15 @@ public function testPlatformOptionsChangedColumnComparison(): void
7979

8080
$onlineTable = clone $table;
8181
$table->getColumn('test')
82-
->setPlatformOption('jsonb', true);
82+
->setType(Type::getType(Types::JSONB));
8383

8484
$compareResult = $this->comparator->compareTables($onlineTable, $table);
8585
self::assertCount(1, $compareResult->getChangedColumns());
8686
self::assertCount(1, $compareResult->getModifiedColumns());
8787

8888
$changedColumn = $compareResult->getChangedColumns()['test'];
8989

90-
self::assertTrue($changedColumn->hasPlatformOptionsChanged());
90+
self::assertTrue($changedColumn->hasTypeChanged());
9191
self::assertEquals(1, $changedColumn->countChangedProperties());
9292
}
9393

tests/Functional/Schema/PostgreSQLSchemaManagerTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Doctrine\DBAL\Types\BlobType;
1515
use Doctrine\DBAL\Types\DecimalType;
1616
use Doctrine\DBAL\Types\IntegerType;
17-
use Doctrine\DBAL\Types\JsonType;
17+
use Doctrine\DBAL\Types\JsonbType;
1818
use Doctrine\DBAL\Types\TextType;
1919
use Doctrine\DBAL\Types\Type;
2020
use Doctrine\DBAL\Types\Types;
@@ -323,13 +323,12 @@ public function testPartialIndexes(): void
323323
public function testJsonbColumn(): void
324324
{
325325
$table = new Table('test_jsonb');
326-
$table->addColumn('foo', Types::JSON)->setPlatformOption('jsonb', true);
326+
$table->addColumn('foo', Types::JSONB);
327327
$this->dropAndCreateTable($table);
328328

329329
$columns = $this->schemaManager->listTableColumns('test_jsonb');
330330

331-
self::assertInstanceOf(JsonType::class, $columns['foo']->getType());
332-
self::assertTrue($columns['foo']->getPlatformOption('jsonb'));
331+
self::assertInstanceOf(JsonbType::class, $columns['foo']->getType());
333332
}
334333

335334
public function testListNegativeColumnDefaultValue(): void

tests/Platforms/AbstractMySQLPlatformTestCase.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,6 @@ public function testModifyLimitQueryWithEmptyOffset(): void
177177

178178
public function testGetDateTimeTypeDeclarationSql(): void
179179
{
180-
self::assertEquals('DATETIME', $this->platform->getDateTimeTypeDeclarationSQL(['version' => false]));
181-
self::assertEquals('TIMESTAMP', $this->platform->getDateTimeTypeDeclarationSQL(['version' => true]));
182180
self::assertEquals('DATETIME', $this->platform->getDateTimeTypeDeclarationSQL([]));
183181
}
184182

tests/Platforms/AbstractPlatformTestCase.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
use Doctrine\DBAL\Schema\TableDiff;
3030
use Doctrine\DBAL\Types\Type;
3131
use Doctrine\DBAL\Types\Types;
32-
use Doctrine\Deprecations\PHPUnit\VerifyDeprecations;
3332
use PHPUnit\Framework\Attributes\DataProvider;
3433
use PHPUnit\Framework\Attributes\TestWith;
3534
use PHPUnit\Framework\TestCase;
@@ -40,8 +39,6 @@
4039
/** @template T of AbstractPlatform */
4140
abstract class AbstractPlatformTestCase extends TestCase
4241
{
43-
use VerifyDeprecations;
44-
4542
/** @var T */
4643
protected AbstractPlatform $platform;
4744

@@ -549,10 +546,8 @@ public function testReturnsJsonTypeDeclarationSQL(): void
549546

550547
public function testReturnsJsonbTypeDeclarationSQL(): void
551548
{
552-
$this->expectDeprecationWithIdentifier('https://github.com/doctrine/dbal/pull/6939');
553-
554549
self::assertSame(
555-
$this->platform->getJsonTypeDeclarationSQL(['jsonb' => true]),
550+
$this->platform->getJsonTypeDeclarationSQL([]),
556551
$this->platform->getJsonbTypeDeclarationSQL([]),
557552
);
558553
}

tests/Platforms/DB2PlatformTest.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -230,12 +230,6 @@ public function testGeneratesColumnTypesDeclarationSQL(): void
230230
self::assertEquals('SMALLINT', $this->platform->getBooleanTypeDeclarationSQL($fullColumnDef));
231231
self::assertEquals('CLOB(1M)', $this->platform->getClobTypeDeclarationSQL($fullColumnDef));
232232
self::assertEquals('DATE', $this->platform->getDateTypeDeclarationSQL($fullColumnDef));
233-
234-
self::assertEquals(
235-
'TIMESTAMP(0) WITH DEFAULT',
236-
$this->platform->getDateTimeTypeDeclarationSQL(['version' => true]),
237-
);
238-
239233
self::assertEquals('TIMESTAMP(0)', $this->platform->getDateTimeTypeDeclarationSQL($fullColumnDef));
240234
self::assertEquals('TIME', $this->platform->getTimeTypeDeclarationSQL($fullColumnDef));
241235
}

0 commit comments

Comments
 (0)