Commit 328153bd authored by Marco Pivetta's avatar Marco Pivetta

Merge pull request #705 from deeky666/DBAL-1025

[DBAL-1025] Allow connecting without database name for sqlanywhere driver
parents 57dc9dd3 9fa4842c
...@@ -47,17 +47,13 @@ class Driver extends AbstractSQLAnywhereDriver ...@@ -47,17 +47,13 @@ class Driver extends AbstractSQLAnywhereDriver
throw new SQLAnywhereException("Missing 'server' in configuration for sqlanywhere driver."); throw new SQLAnywhereException("Missing 'server' in configuration for sqlanywhere driver.");
} }
if ( ! isset($params['dbname'])) {
throw new SQLAnywhereException("Missing 'dbname' in configuration for sqlanywhere driver.");
}
try { try {
return new SQLAnywhereConnection( return new SQLAnywhereConnection(
$this->buildDsn( $this->buildDsn(
$params['host'], $params['host'],
isset($params['port']) ? $params['port'] : null, isset($params['port']) ? $params['port'] : null,
$params['server'], $params['server'],
$params['dbname'], isset($params['dbname']) ? $params['dbname'] : null,
$username, $username,
$password, $password,
$driverOptions $driverOptions
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace Doctrine\Tests\DBAL\Functional; namespace Doctrine\Tests\DBAL\Functional;
use Doctrine\DBAL\ConnectionException; use Doctrine\DBAL\ConnectionException;
use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Type;
require_once __DIR__ . '/../../TestInit.php'; require_once __DIR__ . '/../../TestInit.php';
...@@ -223,4 +224,25 @@ class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -223,4 +224,25 @@ class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase
$this->assertTrue($this->_conn->ping()); $this->assertTrue($this->_conn->ping());
$this->assertTrue($this->_conn->isConnected()); $this->assertTrue($this->_conn->isConnected());
} }
/**
* @group DBAL-1025
*/
public function testConnectWithoutExplicitDatabaseName()
{
if (in_array($this->_conn->getDatabasePlatform()->getName(), array('oracle', 'db2'), true)) {
$this->markTestSkipped('Platform does not support connecting without database name.');
}
$params = $this->_conn->getParams();
unset($params['dbname']);
$connection = DriverManager::getConnection(
$params,
$this->_conn->getConfiguration(),
$this->_conn->getEventManager()
);
$this->assertTrue($connection->connect());
}
} }
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