Skip to content

Commit 9b2f648

Browse files
Fix bug about get default params on PoolingShardConnection
1 parent f44782e commit 9b2f648

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

lib/Doctrine/DBAL/Sharding/PoolingShardConnection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public function getActiveShardId()
141141
*/
142142
public function getParams()
143143
{
144-
return $this->activeShardId ? $this->connections[$this->activeShardId] : parent::getParams();
144+
return $this->activeShardId ? $this->connections[$this->activeShardId] : $this->connections[0];
145145
}
146146

147147
/**

tests/Doctrine/Tests/DBAL/Sharding/PoolingShardConnectionTest.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,34 +209,37 @@ public function testGetParamsOverride()
209209
$conn = DriverManager::getConnection(array(
210210
'wrapperClass' => 'Doctrine\DBAL\Sharding\PoolingShardConnection',
211211
'driver' => 'pdo_sqlite',
212-
'global' => array('memory' => true),
212+
'global' => array('memory' => true, 'host' => 'localhost'),
213213
'shards' => array(
214-
array('id' => 1, 'memory' => true),
214+
array('id' => 1, 'memory' => true, 'host' => 'foo'),
215215
),
216216
'shardChoser' => 'Doctrine\DBAL\Sharding\ShardChoser\MultiTenantShardChoser',
217217
));
218218

219219
$this->assertEquals(array(
220220
'wrapperClass' => 'Doctrine\DBAL\Sharding\PoolingShardConnection',
221221
'driver' => 'pdo_sqlite',
222-
'global' => array('memory' => true),
222+
'global' => array('memory' => true, 'host' => 'localhost'),
223223
'shards' => array(
224-
array('id' => 1, 'memory' => true),
224+
array('id' => 1, 'memory' => true, 'host' => 'foo'),
225225
),
226226
'shardChoser' => new MultiTenantShardChoser(),
227+
'memory' => true,
228+
'host' => 'localhost',
227229
), $conn->getParams());
228230

229231
$conn->connect(1);
230232
$this->assertEquals(array(
231233
'wrapperClass' => 'Doctrine\DBAL\Sharding\PoolingShardConnection',
232234
'driver' => 'pdo_sqlite',
233-
'global' => array('memory' => true),
235+
'global' => array('memory' => true, 'host' => 'localhost'),
234236
'shards' => array(
235-
array('id' => 1, 'memory' => true),
237+
array('id' => 1, 'memory' => true, 'host' => 'foo'),
236238
),
237239
'shardChoser' => new MultiTenantShardChoser(),
238240
'id' => 1,
239241
'memory' => true,
242+
'host' => 'foo',
240243
), $conn->getParams());
241244
}
242245

0 commit comments

Comments
 (0)