Skip to content

Commit

Permalink
Update according to changes in db (#330)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tigrov authored Dec 8, 2024
1 parent 84486b5 commit a56c69a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Enh #324: Set more specific result type in `Connection` methods `createCommand()` and `createTransaction()` (@vjik)
- Enh #326: Refactor `Schema::normalizeDefaultValue()` method and move it to `ColumnFactory` class (@Tigrov)
- New #328: Override `QueryBuilder::prepareBinary()` method (@Tigrov)
- Chg #330: Update `QueryBuilder` constructor (@Tigrov)

## 1.2.0 March 21, 2024

Expand Down
13 changes: 5 additions & 8 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,11 @@ public function createTransaction(): Transaction

public function getQueryBuilder(): QueryBuilderInterface
{
if ($this->queryBuilder === null) {
$this->queryBuilder = new QueryBuilder(
$this->getQuoter(),
$this->getSchema(),
);
}

return $this->queryBuilder;
return $this->queryBuilder ??= new QueryBuilder(
$this->getQuoter(),
$this->getSchema(),
$this->getServerInfo(),
);
}

public function getQuoter(): QuoterInterface
Expand Down
18 changes: 11 additions & 7 deletions src/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Yiisoft\Db\Sqlite;

use Yiisoft\Db\Connection\ServerInfoInterface;
use Yiisoft\Db\Constant\ColumnType;
use Yiisoft\Db\Constant\PseudoType;
use Yiisoft\Db\QueryBuilder\AbstractQueryBuilder;
Expand Down Expand Up @@ -48,14 +49,17 @@ final class QueryBuilder extends AbstractQueryBuilder
ColumnType::JSON => 'json',
];

public function __construct(QuoterInterface $quoter, SchemaInterface $schema)
public function __construct(QuoterInterface $quoter, SchemaInterface $schema, ServerInfoInterface $serverInfo)
{
$ddlBuilder = new DDLQueryBuilder($this, $quoter, $schema);
$dmlBuilder = new DMLQueryBuilder($this, $quoter, $schema);
$dqlBuilder = new DQLQueryBuilder($this, $quoter);
$columnDefinitionBuilder = new ColumnDefinitionBuilder($this);

parent::__construct($quoter, $schema, $ddlBuilder, $dmlBuilder, $dqlBuilder, $columnDefinitionBuilder);
parent::__construct(
$quoter,
$schema,
$serverInfo,
new DDLQueryBuilder($this, $quoter, $schema),
new DMLQueryBuilder($this, $quoter, $schema),
new DQLQueryBuilder($this, $quoter),
new ColumnDefinitionBuilder($this),
);
}

protected function prepareBinary(string $binary): string
Expand Down
2 changes: 1 addition & 1 deletion tests/CommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ public function testUpsert(array $firstData, array $secondData): void
{
$db = $this->getConnection();

if (version_compare($db->getServerVersion(), '3.8.3', '<')) {
if (version_compare($db->getServerInfo()->getVersion(), '3.8.3', '<')) {
$this->markTestSkipped('SQLite < 3.8.3 does not support "WITH" keyword.');
}

Expand Down

0 comments on commit a56c69a

Please sign in to comment.