Skip to content

Commit

Permalink
Merge pull request #912 from vincentchalamon/master
Browse files Browse the repository at this point in the history
Fix bug about get default params on PoolingShardConnection
  • Loading branch information
deeky666 committed Oct 16, 2015
2 parents 532641f + 9b2f648 commit 81b500d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Sharding/PoolingShardConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public function getActiveShardId()
*/
public function getParams()
{
return $this->activeShardId ? $this->connections[$this->activeShardId] : parent::getParams();
return $this->activeShardId ? $this->connections[$this->activeShardId] : $this->connections[0];
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,34 +209,37 @@ public function testGetParamsOverride()
$conn = DriverManager::getConnection(array(
'wrapperClass' => 'Doctrine\DBAL\Sharding\PoolingShardConnection',
'driver' => 'pdo_sqlite',
'global' => array('memory' => true),
'global' => array('memory' => true, 'host' => 'localhost'),
'shards' => array(
array('id' => 1, 'memory' => true),
array('id' => 1, 'memory' => true, 'host' => 'foo'),
),
'shardChoser' => 'Doctrine\DBAL\Sharding\ShardChoser\MultiTenantShardChoser',
));

$this->assertEquals(array(
'wrapperClass' => 'Doctrine\DBAL\Sharding\PoolingShardConnection',
'driver' => 'pdo_sqlite',
'global' => array('memory' => true),
'global' => array('memory' => true, 'host' => 'localhost'),
'shards' => array(
array('id' => 1, 'memory' => true),
array('id' => 1, 'memory' => true, 'host' => 'foo'),
),
'shardChoser' => new MultiTenantShardChoser(),
'memory' => true,
'host' => 'localhost',
), $conn->getParams());

$conn->connect(1);
$this->assertEquals(array(
'wrapperClass' => 'Doctrine\DBAL\Sharding\PoolingShardConnection',
'driver' => 'pdo_sqlite',
'global' => array('memory' => true),
'global' => array('memory' => true, 'host' => 'localhost'),
'shards' => array(
array('id' => 1, 'memory' => true),
array('id' => 1, 'memory' => true, 'host' => 'foo'),
),
'shardChoser' => new MultiTenantShardChoser(),
'id' => 1,
'memory' => true,
'host' => 'foo',
), $conn->getParams());
}

Expand Down

0 comments on commit 81b500d

Please sign in to comment.