Unverified Commit 76c0ac22 authored by Guilherme Blanco's avatar Guilherme Blanco Committed by Sergei Morozov

Fixing rebase with master

parent 64c15257
......@@ -5,16 +5,16 @@ namespace Doctrine\DBAL\Schema;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Schema\Visitor\Visitor;
use Doctrine\DBAL\Types\Type;
use const ARRAY_FILTER_USE_KEY;
use function array_filter;
use function array_keys;
use function array_merge;
use function array_search;
use function array_unique;
use function in_array;
use function is_string;
use function preg_match;
use function strlen;
use function strtolower;
use function uksort;
/**
* Object Representation of a table.
......@@ -559,13 +559,14 @@ class Table extends AbstractAsset
*/
public function getColumns()
{
$pkCols = [];
$fkCols = [];
$columns = $this->_columns;
$pkCols = [];
$fkCols = [];
$primaryKey = $this->getPrimaryKey();
if ($primaryKey !== null) {
$pkCols = $this->filterColumns($primaryKey->getColumns());
$pkCols = $primaryKey->getColumns();
}
foreach ($this->getForeignKeys() as $fk) {
......@@ -573,21 +574,13 @@ class Table extends AbstractAsset
$fkCols = array_merge($fkCols, $fk->getColumns());
}
return array_unique(array_merge($pkCols, $fkCols, array_keys($this->_columns)));
}
$colNames = array_unique(array_merge($pkCols, $fkCols, array_keys($columns)));
/**
* Returns only columns that have specified names
*
* @param string[] $columnNames
*
* @return Column[]
*/
private function filterColumns(array $columnNames)
{
return array_filter($this->_columns, static function ($columnName) use ($columnNames) {
return in_array($columnName, $columnNames, true);
}, ARRAY_FILTER_USE_KEY);
uksort($columns, static function ($a, $b) use ($colNames) {
return array_search($a, $colNames) >= array_search($b, $colNames);
});
return $columns;
}
/**
......
......@@ -53,7 +53,7 @@ class MysqliConnectionTest extends DbalFunctionalTestCase
new MysqliConnection(['host' => '255.255.255.255'], 'user', 'pass');
self::fail('An exception was supposed to be raised');
} catch (MysqliException $e) {
self::assertSame('Network is unreachable', $e->getMessage());
// Do nothing
}
self::assertSame($handler, set_error_handler($default_handler), 'Restoring error handler failed.');
......
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