Unverified Commit 5e7ceff8 authored by Michael Moravec's avatar Michael Moravec Committed by Sergei Morozov

Remove deprecated AbstractSchemaManager::getFilterSchemaAssetsExpression(),...

Remove deprecated AbstractSchemaManager::getFilterSchemaAssetsExpression(), Configuration::getFilterSchemaAssetsExpression() and Configuration::getFilterSchemaAssetsExpression()
parent 318c15b4
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
* Removed `Table::addUnnamedForeignKeyConstraint()` and `Table::addNamedForeignKeyConstraint()`. * Removed `Table::addUnnamedForeignKeyConstraint()` and `Table::addNamedForeignKeyConstraint()`.
* Removed `Table::renameColumn()`. * Removed `Table::renameColumn()`.
* Removed `SQLParserUtils::getPlaceholderPositions()`. * Removed `SQLParserUtils::getPlaceholderPositions()`.
* Removed `AbstractSchemaManager::getFilterSchemaAssetsExpression()`, `Configuration::getFilterSchemaAssetsExpression()`
and `Configuration::getFilterSchemaAssetsExpression()`.
* `SQLParserUtils::*_TOKEN` constants made private. * `SQLParserUtils::*_TOKEN` constants made private.
## BC BREAK changes the `Driver::connect()` signature ## BC BREAK changes the `Driver::connect()` signature
......
...@@ -87,18 +87,6 @@ class Configuration ...@@ -87,18 +87,6 @@ class Configuration
} }
} }
/**
* Returns filter schema assets expression.
*
* @deprecated Use Configuration::getSchemaAssetsFilter() instead
*
* @return string|null
*/
public function getFilterSchemaAssetsExpression()
{
return $this->_attributes['filterSchemaAssetsExpression'] ?? null;
}
/** /**
* @param string $filterExpression * @param string $filterExpression
*/ */
......
...@@ -235,16 +235,6 @@ abstract class AbstractSchemaManager ...@@ -235,16 +235,6 @@ abstract class AbstractSchemaManager
return array_values(array_filter($assetNames, $filter)); return array_values(array_filter($assetNames, $filter));
} }
/**
* @deprecated Use Configuration::getSchemaAssetsFilter() instead
*
* @return string|null
*/
protected function getFilterSchemaAssetsExpression()
{
return $this->_conn->getConfiguration()->getFilterSchemaAssetsExpression();
}
/** /**
* Lists the tables for this connection. * Lists the tables for this connection.
* *
......
...@@ -18,6 +18,7 @@ use Doctrine\DBAL\Types\Types; ...@@ -18,6 +18,7 @@ use Doctrine\DBAL\Types\Types;
use function array_map; use function array_map;
use function array_pop; use function array_pop;
use function count; use function count;
use function preg_match;
use function strtolower; use function strtolower;
class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
...@@ -217,11 +218,15 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase ...@@ -217,11 +218,15 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
$column = $testTable->addColumn('id', 'integer'); $column = $testTable->addColumn('id', 'integer');
$this->schemaManager->createTable($testTable); $this->schemaManager->createTable($testTable);
$this->connection->getConfiguration()->setFilterSchemaAssetsExpression('#^dbal204_#'); $this->connection->getConfiguration()->setSchemaAssetsFilter(static function (string $name): bool {
return preg_match('#^dbal204_#', $name) === 1;
});
$names = $this->schemaManager->listTableNames(); $names = $this->schemaManager->listTableNames();
self::assertCount(2, $names); self::assertCount(2, $names);
$this->connection->getConfiguration()->setFilterSchemaAssetsExpression('#^dbal204_test#'); $this->connection->getConfiguration()->setSchemaAssetsFilter(static function (string $name): bool {
return preg_match('#^dbal204_test#', $name) === 1;
});
$names = $this->schemaManager->listTableNames(); $names = $this->schemaManager->listTableNames();
self::assertCount(1, $names); self::assertCount(1, $names);
} }
......
...@@ -12,6 +12,7 @@ use PHPUnit\Framework\MockObject\MockObject; ...@@ -12,6 +12,7 @@ use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use function in_array; use function in_array;
use function preg_match;
/** /**
* @covers \Doctrine\DBAL\Schema\DB2SchemaManager * @covers \Doctrine\DBAL\Schema\DB2SchemaManager
...@@ -44,8 +45,10 @@ final class DB2SchemaManagerTest extends TestCase ...@@ -44,8 +45,10 @@ final class DB2SchemaManagerTest extends TestCase
*/ */
public function testListTableNamesFiltersAssetNamesCorrectly(): void public function testListTableNamesFiltersAssetNamesCorrectly(): void
{ {
$this->conn->getConfiguration()->setFilterSchemaAssetsExpression('/^(?!T_)/'); $this->conn->getConfiguration()->setSchemaAssetsFilter(static function (string $name): bool {
$this->conn->expects(self::once())->method('fetchAllAssociative')->will(self::returnValue([ return preg_match('/^(?!T_)/', $name) === 1;
});
$this->conn->expects(self::once())->method('fetchAllAssociative')->will($this->returnValue([
['name' => 'FOO'], ['name' => 'FOO'],
['name' => 'T_FOO'], ['name' => 'T_FOO'],
['name' => 'BAR'], ['name' => 'BAR'],
...@@ -61,35 +64,6 @@ final class DB2SchemaManagerTest extends TestCase ...@@ -61,35 +64,6 @@ final class DB2SchemaManagerTest extends TestCase
); );
} }
/**
* @group DBAL-2701
*/
public function testAssetFilteringSetsACallable(): void
{
$filterExpression = '/^(?!T_)/';
$this->conn->getConfiguration()->setFilterSchemaAssetsExpression($filterExpression);
$this->conn->expects(self::once())->method('fetchAllAssociative')->will(self::returnValue([
['name' => 'FOO'],
['name' => 'T_FOO'],
['name' => 'BAR'],
['name' => 'T_BAR'],
]));
self::assertSame(
[
'FOO',
'BAR',
],
$this->manager->listTableNames()
);
$callable = $this->conn->getConfiguration()->getSchemaAssetsFilter();
self::assertIsCallable($callable);
// BC check: Test that regexp expression is still preserved & accessible.
self::assertEquals($filterExpression, $this->conn->getConfiguration()->getFilterSchemaAssetsExpression());
}
public function testListTableNamesFiltersAssetNamesCorrectlyWithCallable(): void public function testListTableNamesFiltersAssetNamesCorrectlyWithCallable(): void
{ {
$accepted = ['T_FOO', 'T_BAR']; $accepted = ['T_FOO', 'T_BAR'];
...@@ -111,79 +85,5 @@ final class DB2SchemaManagerTest extends TestCase ...@@ -111,79 +85,5 @@ final class DB2SchemaManagerTest extends TestCase
], ],
$this->manager->listTableNames() $this->manager->listTableNames()
); );
self::assertNull($this->conn->getConfiguration()->getFilterSchemaAssetsExpression());
}
public function testSettingNullExpressionWillResetCallable(): void
{
$accepted = ['T_FOO', 'T_BAR'];
$this->conn->getConfiguration()->setSchemaAssetsFilter(static function ($assetName) use ($accepted) {
return in_array($assetName, $accepted);
});
$this->conn->expects(self::any())->method('quote');
$this->conn->expects($this->atLeastOnce())->method('fetchAllAssociative')->will(self::returnValue([
['name' => 'FOO'],
['name' => 'T_FOO'],
['name' => 'BAR'],
['name' => 'T_BAR'],
]));
self::assertSame(
[
'T_FOO',
'T_BAR',
],
$this->manager->listTableNames()
);
$this->conn->getConfiguration()->setFilterSchemaAssetsExpression(null);
self::assertSame(
[
'FOO',
'T_FOO',
'BAR',
'T_BAR',
],
$this->manager->listTableNames()
);
self::assertNull($this->conn->getConfiguration()->getSchemaAssetsFilter());
}
public function testSettingNullAsCallableClearsExpression(): void
{
$filterExpression = '/^(?!T_)/';
$this->conn->getConfiguration()->setFilterSchemaAssetsExpression($filterExpression);
$this->conn->expects(self::exactly(2))->method('fetchAllAssociative')->will(self::returnValue([
['name' => 'FOO'],
['name' => 'T_FOO'],
['name' => 'BAR'],
['name' => 'T_BAR'],
]));
self::assertSame(
[
'FOO',
'BAR',
],
$this->manager->listTableNames()
);
$this->conn->getConfiguration()->setSchemaAssetsFilter(null);
self::assertSame(
[
'FOO',
'T_FOO',
'BAR',
'T_BAR',
],
$this->manager->listTableNames()
);
$this->assertNull($this->conn->getConfiguration()->getFilterSchemaAssetsExpression());
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment