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

Deprecate TableGenerator #4681

Merged
merged 1 commit into from
Jun 19, 2021
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
5 changes: 5 additions & 0 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@
is no longer supported.
-->
<file name="tests/Functional/ResultCacheTest.php"/>
<!--
This suppression should be removed in 4.0.0.
-->
<referencedClass name="Doctrine\DBAL\Id\TableGenerator"/>
<referencedClass name="Doctrine\DBAL\Id\TableGeneratorSchemaVisitor"/>
</errorLevel>
</DeprecatedClass>
<DeprecatedMethod>
Expand Down
9 changes: 9 additions & 0 deletions src/Id/TableGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\Exception;
use Doctrine\DBAL\LockMode;
use Doctrine\Deprecations\Deprecation;
use Throwable;

use function array_change_key_case;
Expand Down Expand Up @@ -51,6 +52,8 @@
*
* If no row is present for a given sequence a new one will be created with the
* default values 'value' = 1 and 'increment_by' = 1
*
* @deprecated
*/
class TableGenerator
{
Expand All @@ -70,6 +73,12 @@ class TableGenerator
*/
public function __construct(Connection $conn, $generatorTableName = 'sequences')
{
Deprecation::trigger(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/4681',
'The TableGenerator class is is deprecated.',
);

if ($conn->getDriver() instanceof Driver\PDO\SQLite\Driver) {
throw new Exception('Cannot use TableGenerator with SQLite.');
}
Expand Down
10 changes: 10 additions & 0 deletions src/Id/TableGeneratorSchemaVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
use Doctrine\DBAL\Schema\Sequence;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\Visitor\Visitor;
use Doctrine\Deprecations\Deprecation;

/**
* @deprecated
*/
class TableGeneratorSchemaVisitor implements Visitor
{
/** @var string */
Expand All @@ -20,6 +24,12 @@ class TableGeneratorSchemaVisitor implements Visitor
*/
public function __construct($generatorTableName = 'sequences')
{
Deprecation::trigger(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/4681',
'The TableGeneratorSchemaVisitor class is is deprecated.',
);

$this->generatorTableName = $generatorTableName;
}

Expand Down