Skip to content

Commit

Permalink
Merge branch 'bpo/2.9/#3642' into 2.9
Browse files Browse the repository at this point in the history
  • Loading branch information
morozov committed Oct 26, 2019
2 parents 8bd299f + 61b652d commit 94b1ea2
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 3 deletions.
6 changes: 5 additions & 1 deletion lib/Doctrine/DBAL/Driver/OCI8/OCI8Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@
class OCI8Exception extends AbstractDriverException
{
/**
* @param mixed[] $error
* @param mixed[]|false $error
*
* @return \Doctrine\DBAL\Driver\OCI8\OCI8Exception
*/
public static function fromErrorInfo($error)
{
if ($error === false) {
return new self('Database error occurred but no error information was retrieved from the driver.');
}

return new self($error['message'], null, $error['code']);
}
}
7 changes: 7 additions & 0 deletions lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -296,13 +296,20 @@ public function listTableDetails($tableName)

$tableOptions = $this->_conn->fetchAssoc($sql);

if ($tableOptions === false) {
return $table;
}

$table->addOption('engine', $tableOptions['ENGINE']);

if ($tableOptions['TABLE_COLLATION'] !== null) {
$table->addOption('collation', $tableOptions['TABLE_COLLATION']);
}

if ($tableOptions['AUTO_INCREMENT'] !== null) {
$table->addOption('autoincrement', $tableOptions['AUTO_INCREMENT']);
}

$table->addOption('comment', $tableOptions['TABLE_COMMENT']);
$table->addOption('create_options', $this->parseCreateOptions($tableOptions['CREATE_OPTIONS']));

Expand Down
6 changes: 4 additions & 2 deletions lib/Doctrine/DBAL/Schema/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ class Table extends AbstractAsset
protected $_fkConstraints = [];

/** @var mixed[] */
protected $_options = [];
protected $_options = [
'create_options' => [],
];

/** @var SchemaConfig|null */
protected $_schemaConfig = null;
Expand Down Expand Up @@ -72,7 +74,7 @@ public function __construct($tableName, array $columns = [], array $indexes = []
$this->_addForeignKeyConstraint($constraint);
}

$this->_options = $options;
$this->_options = array_merge($this->_options, $options);
}

/**
Expand Down
5 changes: 5 additions & 0 deletions tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ public function testExecute(array $params)
$this->equalTo($params[2])
);

// the return value is irrelevant to the test
// but it has to be compatible with the method signature
$statement->method('errorInfo')
->willReturn(false);

// can't pass to constructor since we don't have a real database handle,
// but execute must check the connection for the executeMode
$conn = $this->getMockBuilder(OCI8Connection::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ public function testSelectGlobal()
{
$conn = $this->createConnectionMock();
$conn->expects($this->once())->method('connect')->with($this->equalTo(0));
$conn->method('getParams')
->willReturn([
'shardChoser' => $this->createMock(ShardChoser::class),
]);

$shardManager = new PoolingShardManager($conn);
$shardManager->selectGlobal();
Expand Down

0 comments on commit 94b1ea2

Please sign in to comment.