From 24455188bad106f6c8035fff5028c8f6d0e7014c Mon Sep 17 00:00:00 2001 From: eltharin Date: Fri, 17 Jan 2025 22:15:42 +0100 Subject: [PATCH] add $filterAssetNames to get assert tables add a parameter to can get all tables (with asserts), use for a bug in migrations, TableMetadataStorage appear as not initialized --- src/Schema/AbstractSchemaManager.php | 25 +++++++++++++++---------- src/Schema/DB2SchemaManager.php | 4 ++-- src/Schema/MySQLSchemaManager.php | 4 ++-- src/Schema/OracleSchemaManager.php | 4 ++-- src/Schema/PostgreSQLSchemaManager.php | 4 ++-- src/Schema/SQLServerSchemaManager.php | 4 ++-- src/Schema/SqliteSchemaManager.php | 4 ++-- 7 files changed, 27 insertions(+), 22 deletions(-) diff --git a/src/Schema/AbstractSchemaManager.php b/src/Schema/AbstractSchemaManager.php index 2e38bb88ce4..53faa3770d6 100644 --- a/src/Schema/AbstractSchemaManager.php +++ b/src/Schema/AbstractSchemaManager.php @@ -309,7 +309,7 @@ protected function doListTableIndexes($table): array * * @throws Exception */ - public function tablesExist($names) + public function tablesExist($names, bool $filterAssetNames = true) { if (is_string($names)) { Deprecation::trigger( @@ -322,7 +322,12 @@ public function tablesExist($names) $names = array_map('strtolower', (array) $names); - return count($names) === count(array_intersect($names, array_map('strtolower', $this->listTableNames()))); + return count($names) === count( + array_intersect( + $names, + array_map('strtolower', $this->listTableNames($filterAssetNames)), + ), + ); } /** @@ -332,14 +337,14 @@ public function tablesExist($names) * * @throws Exception */ - public function listTableNames() + public function listTableNames(bool $filterAssetNames = true) { $sql = $this->_platform->getListTablesSQL(); $tables = $this->_conn->fetchAllAssociative($sql); $tableNames = $this->_getPortableTablesList($tables); - return $this->filterAssetNames($tableNames); + return $filterAssetNames ? $this->filterAssetNames($tableNames) : $tableNames; } /** @@ -347,16 +352,16 @@ public function listTableNames() * * @throws Exception */ - protected function doListTableNames(): array + protected function doListTableNames(bool $filterAssetNames = true): array { $database = $this->getDatabase(__METHOD__); - return $this->filterAssetNames( - $this->_getPortableTablesList( - $this->selectTableNames($database) - ->fetchAllAssociative(), - ), + $tableNames = $this->_getPortableTablesList( + $this->selectTableNames($database) + ->fetchAllAssociative(), ); + + return $filterAssetNames ? $this->filterAssetNames($tableNames) : $tableNames; } /** diff --git a/src/Schema/DB2SchemaManager.php b/src/Schema/DB2SchemaManager.php index a07136fecb2..8ecf1497c1a 100644 --- a/src/Schema/DB2SchemaManager.php +++ b/src/Schema/DB2SchemaManager.php @@ -30,9 +30,9 @@ class DB2SchemaManager extends AbstractSchemaManager /** * {@inheritDoc} */ - public function listTableNames() + public function listTableNames(bool $filterAssetNames = true) { - return $this->doListTableNames(); + return $this->doListTableNames($filterAssetNames); } /** diff --git a/src/Schema/MySQLSchemaManager.php b/src/Schema/MySQLSchemaManager.php index 6e444d21364..dbdaefe6d45 100644 --- a/src/Schema/MySQLSchemaManager.php +++ b/src/Schema/MySQLSchemaManager.php @@ -53,9 +53,9 @@ class MySQLSchemaManager extends AbstractSchemaManager /** * {@inheritDoc} */ - public function listTableNames() + public function listTableNames(bool $filterAssetNames = true) { - return $this->doListTableNames(); + return $this->doListTableNames($filterAssetNames); } /** diff --git a/src/Schema/OracleSchemaManager.php b/src/Schema/OracleSchemaManager.php index 3608e05660b..94bac5d23fc 100644 --- a/src/Schema/OracleSchemaManager.php +++ b/src/Schema/OracleSchemaManager.php @@ -31,9 +31,9 @@ class OracleSchemaManager extends AbstractSchemaManager /** * {@inheritDoc} */ - public function listTableNames() + public function listTableNames(bool $filterAssetNames = true) { - return $this->doListTableNames(); + return $this->doListTableNames($filterAssetNames); } /** diff --git a/src/Schema/PostgreSQLSchemaManager.php b/src/Schema/PostgreSQLSchemaManager.php index 1716249fc14..f6dc354c282 100644 --- a/src/Schema/PostgreSQLSchemaManager.php +++ b/src/Schema/PostgreSQLSchemaManager.php @@ -43,9 +43,9 @@ class PostgreSQLSchemaManager extends AbstractSchemaManager /** * {@inheritDoc} */ - public function listTableNames() + public function listTableNames(bool $filterAssetNames = true) { - return $this->doListTableNames(); + return $this->doListTableNames($filterAssetNames); } /** diff --git a/src/Schema/SQLServerSchemaManager.php b/src/Schema/SQLServerSchemaManager.php index acef511abea..176058d3c6a 100644 --- a/src/Schema/SQLServerSchemaManager.php +++ b/src/Schema/SQLServerSchemaManager.php @@ -35,9 +35,9 @@ class SQLServerSchemaManager extends AbstractSchemaManager /** * {@inheritDoc} */ - public function listTableNames() + public function listTableNames(bool $filterAssetNames = true) { - return $this->doListTableNames(); + return $this->doListTableNames($filterAssetNames); } /** diff --git a/src/Schema/SqliteSchemaManager.php b/src/Schema/SqliteSchemaManager.php index 3b464f21add..9f52e7b7932 100644 --- a/src/Schema/SqliteSchemaManager.php +++ b/src/Schema/SqliteSchemaManager.php @@ -44,9 +44,9 @@ class SqliteSchemaManager extends AbstractSchemaManager /** * {@inheritDoc} */ - public function listTableNames() + public function listTableNames(bool $filterAssetNames = true) { - return $this->doListTableNames(); + return $this->doListTableNames($filterAssetNames); } /**