diff --git a/Connection.php b/Connection.php index 83aedfe..6f53b9f 100644 --- a/Connection.php +++ b/Connection.php @@ -25,10 +25,6 @@ class Connection extends \yii\db\Connection * @inheritdoc */ public $commandClass = 'bashkarev\clickhouse\Command'; - /** - * @inheritdoc - */ - public $driverName = 'clickhouse'; /** * @var Schema */ @@ -42,6 +38,18 @@ class Connection extends \yii\db\Connection */ private $_configuration; + /** + * @inheritdoc + */ + public function __construct($config = []) + { + if (!isset($config['driverName'])) { + $config['driverName'] = 'clickhouse'; + } + + parent::__construct($config); + } + /** * @inheritdoc */ @@ -149,4 +157,4 @@ public function transaction(callable $callback, $isolationLevel = null) throw new NotSupportedException('In the clickhouse database, transactions are not supported'); } -} \ No newline at end of file +} diff --git a/tests/ConnectionTest.php b/tests/ConnectionTest.php index 1b43150..c1418d6 100644 --- a/tests/ConnectionTest.php +++ b/tests/ConnectionTest.php @@ -59,6 +59,7 @@ public function testGetDriverName() { $connection = $this->getConnection(false, false); $this->assertEquals('clickhouse', $connection->driverName); + $this->assertEquals('clickhouse', $connection->getDriverName()); } public function testQuoteValue()