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

Fixing rebase with master

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