Skip to content

Commit

Permalink
Update according to changes in db (#294)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tigrov authored Dec 8, 2024
1 parent 4e9fa61 commit a7d9d13
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
- Enh #288: Refactor `Schema::findColumns()` method (@Tigrov)
- Enh #289: Refactor `Schema::normalizeDefaultValue()` method and move it to `ColumnFactory` class (@Tigrov)
- New #292: Override `QueryBuilder::prepareBinary()` method (@Tigrov)
- Chg #294: Update `QueryBuilder` constructor (@Tigrov)

## 1.3.0 March 21, 2024

Expand Down
10 changes: 5 additions & 5 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ public function getLastInsertID(string $sequenceName = null): string

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\Oracle;

use Yiisoft\Db\Connection\ServerInfoInterface;
use Yiisoft\Db\Constant\ColumnType;
use Yiisoft\Db\Constant\PseudoType;
use Yiisoft\Db\Oracle\Column\ColumnDefinitionBuilder;
Expand Down Expand Up @@ -47,14 +48,17 @@ final class QueryBuilder extends AbstractQueryBuilder
PseudoType::UUID_PK => 'RAW(16) DEFAULT SYS_GUID() PRIMARY KEY',
];

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/SchemaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function testGetSchemaNames(): void

$schema = $db->getSchema();

if (version_compare($db->getServerVersion(), '12', '>')) {
if (version_compare($db->getServerInfo()->getVersion(), '12', '>')) {
$this->assertContains('SYSBACKUP', $schema->getSchemaNames());
} else {
$this->assertEmpty($schema->getSchemaNames());
Expand Down

0 comments on commit a7d9d13

Please sign in to comment.