Commit 33430b01 authored by Steve Müller's avatar Steve Müller

fix retrieving the database name connected to for SQL Anywhere

parent ded8e089
......@@ -116,7 +116,11 @@ abstract class AbstractSQLAnywhereDriver implements Driver, ExceptionConverterDr
{
$params = $conn->getParams();
return $params['dbname'];
if (isset($params['dbname'])) {
return $params['dbname'];
}
return $conn->query('SELECT DB_NAME()')->fetchColumn();
}
/**
......
<?php
namespace Doctrine\Tests\DBAL\Functional\Driver\SQLAnywhere;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver\SQLAnywhere\Driver;
use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest;
class DriverTest extends AbstractDriverTest
{
protected function setUp()
{
if (! extension_loaded('sqlanywhere')) {
$this->markTestSkipped('sqlanywhere is not installed.');
}
parent::setUp();
if (! $this->_conn->getDriver() instanceof Driver) {
$this->markTestSkipped('sqlanywhere only test.');
}
}
public function testReturnsDatabaseNameWithoutDatabaseNameParameter()
{
$params = $this->_conn->getParams();
unset($params['dbname']);
$connection = new Connection(
$params,
$this->_conn->getDriver(),
$this->_conn->getConfiguration(),
$this->_conn->getEventManager()
);
// SQL Anywhere has no "default" database. The name of the default database
// is defined on server startup and therefore can be arbitrary.
$this->assertInternalType('string', $this->driver->getDatabase($connection));
}
/**
* {@inheritdoc}
*/
protected function createDriver()
{
return new Driver();
}
}
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