Commit d40226cc authored by Steve Müller's avatar Steve Müller

Merge pull request #925 from tornellas/master

Fixing the command when option is CURRENT_SCHEMA
parents db358c83 5b641039
...@@ -69,7 +69,11 @@ class OracleSessionInit implements EventSubscriber ...@@ -69,7 +69,11 @@ class OracleSessionInit implements EventSubscriber
array_change_key_case($this->_defaultSessionVars, \CASE_UPPER); array_change_key_case($this->_defaultSessionVars, \CASE_UPPER);
$vars = array(); $vars = array();
foreach ($this->_defaultSessionVars as $option => $value) { foreach ($this->_defaultSessionVars as $option => $value) {
$vars[] = $option." = '".$value."'"; if ($option === 'CURRENT_SCHEMA') {
$vars[] = $option . " = " . $value;
} else {
$vars[] = $option . " = '" . $value . "'";
}
} }
$sql = "ALTER SESSION SET ".implode(" ", $vars); $sql = "ALTER SESSION SET ".implode(" ", $vars);
$args->getConnection()->executeUpdate($sql); $args->getConnection()->executeUpdate($sql);
......
...@@ -23,9 +23,37 @@ class OracleSessionInitTest extends DbalTestCase ...@@ -23,9 +23,37 @@ class OracleSessionInitTest extends DbalTestCase
$listener->postConnect($eventArgs); $listener->postConnect($eventArgs);
} }
/**
* @group DBAL-1824
*
* @dataProvider getPostConnectWithSessionParameterValuesData
*/
public function testPostConnectQuotesSessionParameterValues($name, $value)
{
$connectionMock = $this->getMockBuilder('Doctrine\DBAL\Connection')
->disableOriginalConstructor()
->getMock();
$connectionMock->expects($this->once())
->method('executeUpdate')
->with($this->stringContains(sprintf('%s = %s', $name, $value)));
$eventArgs = new ConnectionEventArgs($connectionMock);
$listener = new OracleSessionInit(array($name => $value));
$listener->postConnect($eventArgs);
}
public function getPostConnectWithSessionParameterValuesData()
{
return array(
array('CURRENT_SCHEMA', 'foo'),
);
}
public function testGetSubscribedEvents() public function testGetSubscribedEvents()
{ {
$listener = new OracleSessionInit(); $listener = new OracleSessionInit();
$this->assertEquals(array(Events::postConnect), $listener->getSubscribedEvents()); $this->assertEquals(array(Events::postConnect), $listener->getSubscribedEvents());
} }
} }
\ No newline at end of file
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