Make the $tableName argument of _getPortableTableIndexesList() required

1. The argument is always available since the method is only called from listTableIndexes() which requires a table name.
2. The argument itself seems a workaround and only needed to bypass the fact that the SQLiteSchemaManager violates the method contract: instead of reformatting the provided data it fetches more data from the DB schema which requires a table name. This argument should be dropped completely later.
parent 6bed1f4e
...@@ -836,12 +836,11 @@ abstract class AbstractSchemaManager ...@@ -836,12 +836,11 @@ abstract class AbstractSchemaManager
/** /**
* Aggregates and groups the index results according to the required data result. * Aggregates and groups the index results according to the required data result.
* *
* @param mixed[][] $tableIndexRows * @param mixed[][] $tableIndexRows
* @param string|null $tableName
* *
* @return Index[] * @return Index[]
*/ */
protected function _getPortableTableIndexesList($tableIndexRows, $tableName = null) protected function _getPortableTableIndexesList(array $tableIndexRows, string $tableName) : array
{ {
$result = []; $result = [];
foreach ($tableIndexRows as $tableIndex) { foreach ($tableIndexRows as $tableIndex) {
......
...@@ -127,7 +127,7 @@ class DB2SchemaManager extends AbstractSchemaManager ...@@ -127,7 +127,7 @@ class DB2SchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function _getPortableTableIndexesList($tableIndexRows, $tableName = null) protected function _getPortableTableIndexesList(array $tableIndexRows, string $tableName) : array
{ {
foreach ($tableIndexRows as &$tableIndexRow) { foreach ($tableIndexRows as &$tableIndexRow) {
$tableIndexRow = array_change_key_case($tableIndexRow, CASE_LOWER); $tableIndexRow = array_change_key_case($tableIndexRow, CASE_LOWER);
......
...@@ -73,9 +73,9 @@ class MySqlSchemaManager extends AbstractSchemaManager ...@@ -73,9 +73,9 @@ class MySqlSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function _getPortableTableIndexesList($tableIndexes, $tableName = null) protected function _getPortableTableIndexesList(array $tableIndexRows, string $tableName) : array
{ {
foreach ($tableIndexes as $k => $v) { foreach ($tableIndexRows as $k => $v) {
$v = array_change_key_case($v, CASE_LOWER); $v = array_change_key_case($v, CASE_LOWER);
if ($v['key_name'] === 'PRIMARY') { if ($v['key_name'] === 'PRIMARY') {
$v['primary'] = true; $v['primary'] = true;
...@@ -89,10 +89,10 @@ class MySqlSchemaManager extends AbstractSchemaManager ...@@ -89,10 +89,10 @@ class MySqlSchemaManager extends AbstractSchemaManager
} }
$v['length'] = isset($v['sub_part']) ? (int) $v['sub_part'] : null; $v['length'] = isset($v['sub_part']) ? (int) $v['sub_part'] : null;
$tableIndexes[$k] = $v; $tableIndexRows[$k] = $v;
} }
return parent::_getPortableTableIndexesList($tableIndexes, $tableName); return parent::_getPortableTableIndexesList($tableIndexRows, $tableName);
} }
/** /**
......
...@@ -90,10 +90,10 @@ class OracleSchemaManager extends AbstractSchemaManager ...@@ -90,10 +90,10 @@ class OracleSchemaManager extends AbstractSchemaManager
* *
* @link http://ezcomponents.org/docs/api/trunk/DatabaseSchema/ezcDbSchemaPgsqlReader.html * @link http://ezcomponents.org/docs/api/trunk/DatabaseSchema/ezcDbSchemaPgsqlReader.html
*/ */
protected function _getPortableTableIndexesList($tableIndexes, $tableName = null) protected function _getPortableTableIndexesList(array $tableIndexRows, string $tableName) : array
{ {
$indexBuffer = []; $indexBuffer = [];
foreach ($tableIndexes as $tableIndex) { foreach ($tableIndexRows as $tableIndex) {
$tableIndex = array_change_key_case($tableIndex, CASE_LOWER); $tableIndex = array_change_key_case($tableIndex, CASE_LOWER);
$keyName = strtolower($tableIndex['name']); $keyName = strtolower($tableIndex['name']);
......
...@@ -209,10 +209,10 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager ...@@ -209,10 +209,10 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
* *
* @link http://ezcomponents.org/docs/api/trunk/DatabaseSchema/ezcDbSchemaPgsqlReader.html * @link http://ezcomponents.org/docs/api/trunk/DatabaseSchema/ezcDbSchemaPgsqlReader.html
*/ */
protected function _getPortableTableIndexesList($tableIndexes, $tableName = null) protected function _getPortableTableIndexesList(array $tableIndexRows, string $tableName) : array
{ {
$buffer = []; $buffer = [];
foreach ($tableIndexes as $row) { foreach ($tableIndexRows as $row) {
$colNumbers = array_map('intval', explode(' ', $row['indkey'])); $colNumbers = array_map('intval', explode(' ', $row['indkey']));
$columnNameSql = sprintf( $columnNameSql = sprintf(
'SELECT attnum, attname FROM pg_attribute WHERE attrelid=%d AND attnum IN (%s) ORDER BY attnum ASC', 'SELECT attnum, attname FROM pg_attribute WHERE attrelid=%d AND attnum IN (%s) ORDER BY attnum ASC',
......
...@@ -194,7 +194,7 @@ class SQLAnywhereSchemaManager extends AbstractSchemaManager ...@@ -194,7 +194,7 @@ class SQLAnywhereSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function _getPortableTableIndexesList($tableIndexRows, $tableName = null) protected function _getPortableTableIndexesList(array $tableIndexRows, string $tableName) : array
{ {
foreach ($tableIndexRows as &$tableIndex) { foreach ($tableIndexRows as &$tableIndex) {
$tableIndex['primary'] = (bool) $tableIndex['primary']; $tableIndex['primary'] = (bool) $tableIndex['primary'];
......
...@@ -176,7 +176,7 @@ class SQLServerSchemaManager extends AbstractSchemaManager ...@@ -176,7 +176,7 @@ class SQLServerSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function _getPortableTableIndexesList($tableIndexRows, $tableName = null) protected function _getPortableTableIndexesList(array $tableIndexRows, string $tableName) : array
{ {
foreach ($tableIndexRows as &$tableIndex) { foreach ($tableIndexRows as &$tableIndex) {
$tableIndex['non_unique'] = (bool) $tableIndex['non_unique']; $tableIndex['non_unique'] = (bool) $tableIndex['non_unique'];
......
...@@ -163,7 +163,7 @@ class SqliteSchemaManager extends AbstractSchemaManager ...@@ -163,7 +163,7 @@ class SqliteSchemaManager extends AbstractSchemaManager
* *
* @link http://ezcomponents.org/docs/api/trunk/DatabaseSchema/ezcDbSchemaPgsqlReader.html * @link http://ezcomponents.org/docs/api/trunk/DatabaseSchema/ezcDbSchemaPgsqlReader.html
*/ */
protected function _getPortableTableIndexesList($tableIndexes, $tableName = null) protected function _getPortableTableIndexesList(array $tableIndexRows, string $tableName) : array
{ {
$indexBuffer = []; $indexBuffer = [];
...@@ -195,7 +195,7 @@ class SqliteSchemaManager extends AbstractSchemaManager ...@@ -195,7 +195,7 @@ class SqliteSchemaManager extends AbstractSchemaManager
} }
// fetch regular indexes // fetch regular indexes
foreach ($tableIndexes as $tableIndex) { foreach ($tableIndexRows as $tableIndex) {
// Ignore indexes with reserved names, e.g. autoindexes // Ignore indexes with reserved names, e.g. autoindexes
if (strpos($tableIndex['name'], 'sqlite_') === 0) { if (strpos($tableIndex['name'], 'sqlite_') === 0) {
continue; continue;
......
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