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

add filterAssetNames to get asset tables #6729

Open
wants to merge 1 commit into
base: 3.9.x
Choose a base branch
from
Open
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
25 changes: 15 additions & 10 deletions src/Schema/AbstractSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@
*
* @throws Exception
*/
public function tablesExist($names)
public function tablesExist($names, bool $filterAssetNames = true)
{
if (is_string($names)) {
Deprecation::trigger(
Expand All @@ -322,7 +322,12 @@

$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)),
),
);
}

/**
Expand All @@ -332,31 +337,31 @@
*
* @throws Exception
*/
public function listTableNames()
public function listTableNames(bool $filterAssetNames = true)

Check warning on line 340 in src/Schema/AbstractSchemaManager.php

View check run for this annotation

Codecov / codecov/patch

src/Schema/AbstractSchemaManager.php#L340

Added line #L340 was not covered by tests
{
$sql = $this->_platform->getListTablesSQL();

$tables = $this->_conn->fetchAllAssociative($sql);
$tableNames = $this->_getPortableTablesList($tables);

return $this->filterAssetNames($tableNames);
return $filterAssetNames ? $this->filterAssetNames($tableNames) : $tableNames;

Check warning on line 347 in src/Schema/AbstractSchemaManager.php

View check run for this annotation

Codecov / codecov/patch

src/Schema/AbstractSchemaManager.php#L347

Added line #L347 was not covered by tests
}

/**
* @return list<string>
*
* @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;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Schema/DB2SchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
/**
* {@inheritDoc}
*/
public function listTableNames()
public function listTableNames(bool $filterAssetNames = true)

Check warning on line 33 in src/Schema/DB2SchemaManager.php

View check run for this annotation

Codecov / codecov/patch

src/Schema/DB2SchemaManager.php#L33

Added line #L33 was not covered by tests
{
return $this->doListTableNames();
return $this->doListTableNames($filterAssetNames);

Check warning on line 35 in src/Schema/DB2SchemaManager.php

View check run for this annotation

Codecov / codecov/patch

src/Schema/DB2SchemaManager.php#L35

Added line #L35 was not covered by tests
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Schema/MySQLSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@
/**
* {@inheritDoc}
*/
public function listTableNames()
public function listTableNames(bool $filterAssetNames = true)

Check warning on line 56 in src/Schema/MySQLSchemaManager.php

View check run for this annotation

Codecov / codecov/patch

src/Schema/MySQLSchemaManager.php#L56

Added line #L56 was not covered by tests
{
return $this->doListTableNames();
return $this->doListTableNames($filterAssetNames);

Check warning on line 58 in src/Schema/MySQLSchemaManager.php

View check run for this annotation

Codecov / codecov/patch

src/Schema/MySQLSchemaManager.php#L58

Added line #L58 was not covered by tests
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Schema/OracleSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
/**
* {@inheritDoc}
*/
public function listTableNames()
public function listTableNames(bool $filterAssetNames = true)

Check warning on line 34 in src/Schema/OracleSchemaManager.php

View check run for this annotation

Codecov / codecov/patch

src/Schema/OracleSchemaManager.php#L34

Added line #L34 was not covered by tests
{
return $this->doListTableNames();
return $this->doListTableNames($filterAssetNames);

Check warning on line 36 in src/Schema/OracleSchemaManager.php

View check run for this annotation

Codecov / codecov/patch

src/Schema/OracleSchemaManager.php#L36

Added line #L36 was not covered by tests
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Schema/PostgreSQLSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
/**
* {@inheritDoc}
*/
public function listTableNames()
public function listTableNames(bool $filterAssetNames = true)

Check warning on line 46 in src/Schema/PostgreSQLSchemaManager.php

View check run for this annotation

Codecov / codecov/patch

src/Schema/PostgreSQLSchemaManager.php#L46

Added line #L46 was not covered by tests
{
return $this->doListTableNames();
return $this->doListTableNames($filterAssetNames);

Check warning on line 48 in src/Schema/PostgreSQLSchemaManager.php

View check run for this annotation

Codecov / codecov/patch

src/Schema/PostgreSQLSchemaManager.php#L48

Added line #L48 was not covered by tests
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Schema/SQLServerSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Schema/SqliteSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@
/**
* {@inheritDoc}
*/
public function listTableNames()
public function listTableNames(bool $filterAssetNames = true)

Check warning on line 47 in src/Schema/SqliteSchemaManager.php

View check run for this annotation

Codecov / codecov/patch

src/Schema/SqliteSchemaManager.php#L47

Added line #L47 was not covered by tests
{
return $this->doListTableNames();
return $this->doListTableNames($filterAssetNames);

Check warning on line 49 in src/Schema/SqliteSchemaManager.php

View check run for this annotation

Codecov / codecov/patch

src/Schema/SqliteSchemaManager.php#L49

Added line #L49 was not covered by tests
}

/**
Expand Down