Skip to content

Declare abstract AbstractSchemaManager methods as such #5280

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
Feb 16, 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
11 changes: 11 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ awareness about deprecated code.

# Upgrade to 4.0

## Abstract methods in the `AbstractSchemaManager` class have been declared as `abstract`

The following abstract methods in the `AbstractSchemaManager` class have been declared as `abstract`:

- `selectDatabaseColumns()`,
- `selectDatabaseIndexes()`,
- `selectDatabaseForeignKeys()`,
- `getDatabaseTableOptions()`.

Every non-abstract schema manager class must implement them in order to satisfy the API.

# BC Break: The number of affected rows is returned as `int|string`

The signatures of the methods returning the number of affected rows changed as returning `int|string` instead of `int`.
Expand Down
56 changes: 4 additions & 52 deletions src/Schema/AbstractSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,23 +219,6 @@ protected function filterAssetNames(array $assetNames): array
* @throws Exception
*/
public function listTables(): array
{
$tableNames = $this->listTableNames();

$tables = [];
foreach ($tableNames as $tableName) {
$tables[] = $this->listTableDetails($tableName);
}

return $tables;
}

/**
* @return list<Table>
*
* @throws Exception
*/
protected function doListTables(): array
{
$currentDatabase = $this->_conn->getDatabase();

Expand Down Expand Up @@ -282,23 +265,6 @@ protected function doListTables(): array
* @throws Exception
*/
public function listTableDetails(string $name): Table
{
$columns = $this->listTableColumns($name);
$foreignKeys = [];

if ($this->_platform->supportsForeignKeyConstraints()) {
$foreignKeys = $this->listTableForeignKeys($name);
}

$indexes = $this->listTableIndexes($name);

return new Table($name, $columns, $indexes, [], $foreignKeys, []);
}

/**
* @throws Exception
*/
protected function doListTableDetails(string $name): Table
{
$currentDatabase = $this->_conn->getDatabase();

Expand Down Expand Up @@ -353,35 +319,24 @@ protected function normalizeName(string $name): string
* the selection to this table.
*
* @throws Exception
*
* @abstract
*/
protected function selectDatabaseColumns(string $databaseName, ?string $tableName = null): Result
{
throw NotSupported::new(__METHOD__);
}
abstract protected function selectDatabaseColumns(string $databaseName, ?string $tableName = null): Result;

/**
* Selects index definitions of the tables in the specified database. If the table name is specified, narrows down
* the selection to this table.
*
* @throws Exception
*/
protected function selectDatabaseIndexes(string $databaseName, ?string $tableName = null): Result
{
throw NotSupported::new(__METHOD__);
}
abstract protected function selectDatabaseIndexes(string $databaseName, ?string $tableName = null): Result;

/**
* Selects foreign key definitions of the tables in the specified database. If the table name is specified,
* narrows down the selection to this table.
*
* @throws Exception
*/
protected function selectDatabaseForeignKeys(string $databaseName, ?string $tableName = null): Result
{
throw NotSupported::new(__METHOD__);
}
abstract protected function selectDatabaseForeignKeys(string $databaseName, ?string $tableName = null): Result;

/**
* Returns table options for the tables in the specified database. If the table name is specified, narrows down
Expand All @@ -391,10 +346,7 @@ protected function selectDatabaseForeignKeys(string $databaseName, ?string $tabl
*
* @throws Exception
*/
protected function getDatabaseTableOptions(string $databaseName, ?string $tableName = null): array
{
throw NotSupported::new(__METHOD__);
}
abstract protected function getDatabaseTableOptions(string $databaseName, ?string $tableName = null): array;

/**
* Lists the views this connection has.
Expand Down
13 changes: 0 additions & 13 deletions src/Schema/DB2SchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,6 @@ public function listTableNames(): array
return $this->filterAssetNames($this->_getPortableTablesList($tables));
}

/**
* {@inheritDoc}
*/
public function listTables(): array
{
return $this->doListTables();
}

public function listTableDetails(string $name): Table
{
return $this->doListTableDetails($name);
}

/**
* {@inheritdoc}
*
Expand Down
13 changes: 0 additions & 13 deletions src/Schema/MySQLSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,6 @@ class MySQLSchemaManager extends AbstractSchemaManager
"''" => "'",
];

/**
* {@inheritDoc}
*/
public function listTables(): array
{
return $this->doListTables();
}

public function listTableDetails(string $name): Table
{
return $this->doListTableDetails($name);
}

/**
* {@inheritdoc}
*/
Expand Down
13 changes: 0 additions & 13 deletions src/Schema/OracleSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,6 @@
*/
class OracleSchemaManager extends AbstractSchemaManager
{
/**
* {@inheritDoc}
*/
public function listTables(): array
{
return $this->doListTables();
}

public function listTableDetails(string $name): Table
{
return $this->doListTableDetails($name);
}

/**
* {@inheritdoc}
*/
Expand Down
13 changes: 0 additions & 13 deletions src/Schema/PostgreSQLSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,6 @@ class PostgreSQLSchemaManager extends AbstractSchemaManager
{
private ?string $currentSchema = null;

/**
* {@inheritDoc}
*/
public function listTables(): array
{
return $this->doListTables();
}

public function listTableDetails(string $name): Table
{
return $this->doListTableDetails($name);
}

/**
* {@inheritDoc}
*/
Expand Down
13 changes: 0 additions & 13 deletions src/Schema/SQLServerSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,6 @@ class SQLServerSchemaManager extends AbstractSchemaManager
{
private ?string $databaseCollation = null;

/**
* {@inheritDoc}
*/
public function listTables(): array
{
return $this->doListTables();
}

public function listTableDetails(string $name): Table
{
return $this->doListTableDetails($name);
}

/**
* {@inheritDoc}
*/
Expand Down
13 changes: 0 additions & 13 deletions src/Schema/SqliteSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,6 @@
*/
class SqliteSchemaManager extends AbstractSchemaManager
{
/**
* {@inheritDoc}
*/
public function listTables(): array
{
return $this->doListTables();
}

public function listTableDetails(string $name): Table
{
return $this->doListTableDetails($name);
}

public function renameTable(string $name, string $newName): void
{
$tableDiff = new TableDiff($name);
Expand Down