Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
- New #307: Add parameters `$ifExists` and `$cascade` to `CommandInterface::dropTable()` and
`DDLQueryBuilderInterface::dropTable()` methods (@vjik)
- Chg #310: Remove usage of `hasLimit()` and `hasOffset()` methods of `DQLQueryBuilder` class (@Tigrov)
- Enh #313: Refactor according changes in `db` package (@Tigrov)
- New #311: Add `caseSensitive` option to like condition (@vjik)

## 1.3.0 March 21, 2024
Expand Down
2 changes: 1 addition & 1 deletion src/Builder/LikeConditionBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function build(LikeConditionInterface $expression, array &$params = []):
* Different pdo_oci8 versions may or may not implement `PDO::quote()`, so {@see Quoter::quoteValue()} may or
* may not quote `\`.
*/
$this->escapingReplacements['\\'] = substr($this->queryBuilder->quoter()->quoteValue('\\'), 1, -1);
$this->escapingReplacements['\\'] = substr($this->queryBuilder->getQuoter()->quoteValue('\\'), 1, -1);
}

return parent::build($expression, $params);
Expand Down
2 changes: 1 addition & 1 deletion src/Column/ColumnDefinitionBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@

return match ($column->getType()) {
ColumnType::ARRAY, ColumnType::STRUCTURED, ColumnType::JSON =>
' CHECK (' . $this->queryBuilder->quoter()->quoteSimpleColumnName($name) . ' IS JSON)',
' CHECK (' . $this->queryBuilder->getQuoter()->quoteSimpleColumnName($name) . ' IS JSON)',

Check warning on line 65 in src/Column/ColumnDefinitionBuilder.php

View check run for this annotation

Codecov / codecov/patch

src/Column/ColumnDefinitionBuilder.php#L65

Added line #L65 was not covered by tests
default => '',
};
}
Expand Down
25 changes: 10 additions & 15 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
use Yiisoft\Db\Exception\InvalidArgumentException;
use Yiisoft\Db\Exception\InvalidCallException;
use Yiisoft\Db\Exception\InvalidConfigException;
use Yiisoft\Db\Oracle\Column\ColumnFactory;
use Yiisoft\Db\QueryBuilder\QueryBuilderInterface;
use Yiisoft\Db\Schema\Column\ColumnFactoryInterface;
use Yiisoft\Db\Schema\QuoterInterface;
use Yiisoft\Db\Schema\SchemaInterface;
use Yiisoft\Db\Transaction\TransactionInterface;
Expand Down Expand Up @@ -47,6 +49,11 @@ public function createTransaction(): TransactionInterface
return new Transaction($this);
}

public function getColumnFactory(): ColumnFactoryInterface
{
return new ColumnFactory();
}

/**
* Override base behaviour to support Oracle sequences.
*
Expand All @@ -73,28 +80,16 @@ public function getLastInsertID(?string $sequenceName = null): string

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

public function getQuoter(): QuoterInterface
{
if ($this->quoter === null) {
$this->quoter = new Quoter('"', '"', $this->getTablePrefix());
}

return $this->quoter;
return $this->quoter ??= new Quoter('"', '"', $this->getTablePrefix());
}

public function getSchema(): SchemaInterface
{
if ($this->schema === null) {
$this->schema = new Schema($this, $this->schemaCache, strtoupper($this->driver->getUsername()));
}

return $this->schema;
return $this->schema ??= new Schema($this, $this->schemaCache, strtoupper($this->driver->getUsername()));
}
}
13 changes: 6 additions & 7 deletions src/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@

namespace Yiisoft\Db\Oracle;

use Yiisoft\Db\Connection\ServerInfoInterface;
use Yiisoft\Db\Connection\ConnectionInterface;
use Yiisoft\Db\Oracle\Column\ColumnDefinitionBuilder;
use Yiisoft\Db\QueryBuilder\AbstractQueryBuilder;
use Yiisoft\Db\Schema\QuoterInterface;
use Yiisoft\Db\Schema\SchemaInterface;

use function bin2hex;

Expand All @@ -17,12 +15,13 @@
*/
final class QueryBuilder extends AbstractQueryBuilder
{
public function __construct(QuoterInterface $quoter, SchemaInterface $schema, ServerInfoInterface $serverInfo)
public function __construct(ConnectionInterface $db)
{
$quoter = $db->getQuoter();
$schema = $db->getSchema();

parent::__construct(
$quoter,
$schema,
$serverInfo,
$db,
new DDLQueryBuilder($this, $quoter, $schema),
new DMLQueryBuilder($this, $quoter, $schema),
new DQLQueryBuilder($this, $quoter),
Expand Down
9 changes: 1 addition & 8 deletions src/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
use Yiisoft\Db\Exception\InvalidConfigException;
use Yiisoft\Db\Exception\NotSupportedException;
use Yiisoft\Db\Helper\DbArrayHelper;
use Yiisoft\Db\Oracle\Column\ColumnFactory;
use Yiisoft\Db\Schema\Column\ColumnFactoryInterface;
use Yiisoft\Db\Schema\Column\ColumnInterface;
use Yiisoft\Db\Schema\TableSchemaInterface;

Expand Down Expand Up @@ -73,11 +71,6 @@ public function __construct(protected ConnectionInterface $db, SchemaCache $sche
parent::__construct($db, $schemaCache);
}

public function getColumnFactory(): ColumnFactoryInterface
{
return new ColumnFactory();
}

protected function resolveTableName(string $name): TableSchemaInterface
{
$resolvedName = new TableSchema();
Expand Down Expand Up @@ -459,7 +452,7 @@ private function loadColumn(array $info): ColumnInterface
default => null,
};

return $this->getColumnFactory()->fromDbType($dbType, [
return $this->db->getColumnFactory()->fromDbType($dbType, [
'autoIncrement' => $info['identity_column'] === 'YES',
'check' => $info['check'],
'comment' => $info['column_comment'],
Expand Down
8 changes: 8 additions & 0 deletions tests/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Yiisoft\Db\Exception\Exception;
use Yiisoft\Db\Exception\InvalidConfigException;
use Yiisoft\Db\Exception\NotSupportedException;
use Yiisoft\Db\Oracle\Column\ColumnFactory;
use Yiisoft\Db\Oracle\Tests\Support\TestTrait;
use Yiisoft\Db\Tests\Common\CommonConnectionTest;
use Yiisoft\Db\Transaction\TransactionInterface;
Expand Down Expand Up @@ -130,4 +131,11 @@ public function testSerialized(): void
$this->assertEquals(123, $unserialized->createCommand('SELECT 123 FROM DUAL')->queryScalar());
$this->assertNotNull($connection->getPDO());
}

public function testGetColumnFactory(): void
{
$db = $this->getConnection();

$this->assertInstanceOf(ColumnFactory::class, $db->getColumnFactory());
}
}
8 changes: 0 additions & 8 deletions tests/SchemaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use Yiisoft\Db\Exception\Exception;
use Yiisoft\Db\Exception\InvalidConfigException;
use Yiisoft\Db\Exception\NotSupportedException;
use Yiisoft\Db\Oracle\Column\ColumnFactory;
use Yiisoft\Db\Oracle\Schema;
use Yiisoft\Db\Oracle\Tests\Support\TestTrait;
use Yiisoft\Db\Tests\Common\CommonSchemaTest;
Expand Down Expand Up @@ -280,11 +279,4 @@ public function testNotConnectionPDO(): void

$schema->refresh();
}

public function testGetColumnFactory(): void
{
$db = $this->getConnection();

$this->assertInstanceOf(ColumnFactory::class, $db->getSchema()->getColumnFactory());
}
}
Loading