Commit f177f170 by Carsten Brandt

fixed failure on sqlite version check

ensure PDO instance has been created at this point
parent fff48ef7
...@@ -66,6 +66,7 @@ class QueryBuilder extends \yii\db\QueryBuilder ...@@ -66,6 +66,7 @@ class QueryBuilder extends \yii\db\QueryBuilder
{ {
// SQLite supports batch insert natively since 3.7.11 // SQLite supports batch insert natively since 3.7.11
// http://www.sqlite.org/releaselog/3_7_11.html // http://www.sqlite.org/releaselog/3_7_11.html
$this->db->open(); // ensure pdo is not null
if (version_compare($this->db->pdo->getAttribute(\PDO::ATTR_SERVER_VERSION), '3.7.11', '>=')) { if (version_compare($this->db->pdo->getAttribute(\PDO::ATTR_SERVER_VERSION), '3.7.11', '>=')) {
return parent::batchInsert($table, $columns, $rows); return parent::batchInsert($table, $columns, $rows);
} }
......
...@@ -84,7 +84,8 @@ class SqliteQueryBuilderTest extends QueryBuilderTest ...@@ -84,7 +84,8 @@ class SqliteQueryBuilderTest extends QueryBuilderTest
public function testBatchInsert() public function testBatchInsert()
{ {
if (version_compare(\SQLite3::version()['versionString'], '3.7.11', '>=')) { $db = $this->getConnection();
if (version_compare($db->pdo->getAttribute(\PDO::ATTR_SERVER_VERSION), '3.7.11', '>=')) {
$this->markTestSkipped('This test is only relevant for SQLite < 3.7.11'); $this->markTestSkipped('This test is only relevant for SQLite < 3.7.11');
} }
$sql = $this->getQueryBuilder()->batchInsert('{{customer}} t', ['t.id', 't.name'], [[1, 'a'], [2, 'b']]); $sql = $this->getQueryBuilder()->batchInsert('{{customer}} t', ['t.id', 't.name'], [[1, 'a'], [2, 'b']]);
......
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