Skip to content

Remove support for "unique" and "check" column properties #5655

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

Merged
merged 1 commit into from
Sep 18, 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
4 changes: 4 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ awareness about deprecated code.

# Upgrade to 4.0

## BC BREAK: removed support for "unique" and "check" column properties.

The "unique" and "check" column properties are no longer supported.

## BC BREAK: removed default precision and scale of decimal columns.

The DBAL no longer provides default values for precision and scale of decimal columns.
Expand Down
37 changes: 1 addition & 36 deletions src/Platforms/AbstractPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
use Doctrine\DBAL\Types;
use Doctrine\DBAL\Types\Exception\TypeNotFound;
use Doctrine\DBAL\Types\Type;
use Doctrine\Deprecations\Deprecation;
use InvalidArgumentException;
use UnexpectedValueException;

Expand Down Expand Up @@ -1489,19 +1488,15 @@ protected function getRenameIndexSQL(string $oldIndexName, Index $index, string
* Integer value that determines the maximum length of the text
* column. If this argument is missing the column should be
* declared to have the longest length allowed by the DBMS.
*
* default
* Text value to be used as default for this column.
*
* notnull
* Boolean flag that indicates whether this column is constrained
* to not be set to null.
* charset
* Text value with the default CHARACTER SET for this column.
* collation
* Text value with the default COLLATION for this column.
* unique
* unique constraint
*/
public function getColumnDeclarationListSQL(array $columns): string
{
Expand Down Expand Up @@ -1529,21 +1524,15 @@ public function getColumnDeclarationListSQL(array $columns): string
* Integer value that determines the maximum length of the text
* column. If this argument is missing the column should be
* declared to have the longest length allowed by the DBMS.
*
* default
* Text value to be used as default for this column.
*
* notnull
* Boolean flag that indicates whether this column is constrained
* to not be set to null.
* charset
* Text value with the default CHARACTER SET for this column.
* collation
* Text value with the default COLLATION for this column.
* unique
* unique constraint
* check
* column check constraint
* columnDefinition
* a string that defines the complete column
*
Expand All @@ -1566,32 +1555,8 @@ public function getColumnDeclarationSQL(string $name, array $column): string

$notnull = ! empty($column['notnull']) ? ' NOT NULL' : '';

if (! empty($column['unique'])) {
Deprecation::trigger(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/5656',
'The usage of the "unique" column property is deprecated. Use unique constraints instead.',
);

$unique = ' UNIQUE';
} else {
$unique = '';
}

if (! empty($column['check'])) {
Deprecation::trigger(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/5656',
'The usage of the "check" column property is deprecated.',
);

$check = ' ' . $column['check'];
} else {
$check = '';
}

$typeDecl = $column['type']->getSQLDeclaration($column, $this);
$declaration = $typeDecl . $charset . $default . $notnull . $unique . $check . $collation;
$declaration = $typeDecl . $charset . $default . $notnull . $collation;

if ($this->supportsInlineColumnComments() && isset($column['comment']) && $column['comment'] !== '') {
$declaration .= ' ' . $this->getInlineColumnCommentSQL($column['comment']);
Expand Down
32 changes: 4 additions & 28 deletions src/Platforms/OraclePlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ public function getAlterTableSQL(TableDiff $diff): array
public function getColumnDeclarationSQL(string $name, array $column): string
{
if (isset($column['columnDefinition'])) {
$columnDef = $column['columnDefinition'];
$declaration = $column['columnDefinition'];
} else {
$default = $this->getDefaultValueDeclarationSQL($column);

Expand All @@ -667,35 +667,11 @@ public function getColumnDeclarationSQL(string $name, array $column): string
$notnull = $column['notnull'] ? ' NOT NULL' : ' NULL';
}

if (! empty($column['unique'])) {
Deprecation::trigger(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/5656',
'The usage of the "unique" column property is deprecated. Use unique constraints instead.',
);

$unique = ' UNIQUE';
} else {
$unique = '';
}

if (! empty($column['check'])) {
Deprecation::trigger(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/5656',
'The usage of the "check" column property is deprecated.',
);

$check = ' ' . $column['check'];
} else {
$check = '';
}

$typeDecl = $column['type']->getSQLDeclaration($column, $this);
$columnDef = $typeDecl . $default . $notnull . $unique . $check;
$typeDecl = $column['type']->getSQLDeclaration($column, $this);
$declaration = $typeDecl . $default . $notnull;
}

return $name . ' ' . $columnDef;
return $name . ' ' . $declaration;
}

/**
Expand Down
32 changes: 4 additions & 28 deletions src/Platforms/SQLServerPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -1203,42 +1203,18 @@ public function getBlobTypeDeclarationSQL(array $column): string
public function getColumnDeclarationSQL(string $name, array $column): string
{
if (isset($column['columnDefinition'])) {
$columnDef = $column['columnDefinition'];
$declaration = $column['columnDefinition'];
} else {
$collation = ! empty($column['collation']) ?
' ' . $this->getColumnCollationDeclarationSQL($column['collation']) : '';

$notnull = ! empty($column['notnull']) ? ' NOT NULL' : '';

if (! empty($column['unique'])) {
Deprecation::trigger(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/5656',
'The usage of the "unique" column property is deprecated. Use unique constraints instead.',
);

$unique = ' UNIQUE';
} else {
$unique = '';
}

if (! empty($column['check'])) {
Deprecation::trigger(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/5656',
'The usage of the "check" column property is deprecated.',
);

$check = ' ' . $column['check'];
} else {
$check = '';
}

$typeDecl = $column['type']->getSQLDeclaration($column, $this);
$columnDef = $typeDecl . $collation . $notnull . $unique . $check;
$typeDecl = $column['type']->getSQLDeclaration($column, $this);
$declaration = $typeDecl . $collation . $notnull;
}

return $name . ' ' . $columnDef;
return $name . ' ' . $declaration;
}

/**
Expand Down