Skip to content

Commit

Permalink
Fix bug with Quoter
Browse files Browse the repository at this point in the history
  • Loading branch information
Tigrov committed Jan 26, 2024
1 parent 7e37991 commit 277c97e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 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 #801: Deprecate `SchemaInterface::getRawTableName()` and add `QuoterInterface::getRawTableName()` method (@Tigrov)
- Enh #801: Deprecate `SchemaInterface::isReadQuery()` and add `DbStringHelper::isReadQuery()` method (@Tigrov)
- Enh #801: Remove unnecessary symbol `\\` from `rtrim()` function inside `DbStringHelper::baseName()` method (@Tigrov)
- Bug #801: Fix bug with `Quoter::$tablePrefix` when change `AbstractConnection::$tablePrefix` property (@Tigrov)

## 1.2.0 November 12, 2023

Expand Down
3 changes: 3 additions & 0 deletions src/Connection/AbstractConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Yiisoft\Db\Query\BatchQueryResult;
use Yiisoft\Db\Query\BatchQueryResultInterface;
use Yiisoft\Db\Query\QueryInterface;
use Yiisoft\Db\Schema\QuoterInterface;
use Yiisoft\Db\Schema\TableSchemaInterface;
use Yiisoft\Db\Transaction\TransactionInterface;

Expand All @@ -21,6 +22,7 @@
abstract class AbstractConnection implements ConnectionInterface
{
protected TransactionInterface|null $transaction = null;
protected QuoterInterface|null $quoter = null;
private bool $enableSavepoint = true;
private string $tablePrefix = '';

Expand Down Expand Up @@ -71,6 +73,7 @@ public function setEnableSavepoint(bool $value): void
public function setTablePrefix(string $value): void
{
$this->tablePrefix = $value;
$this->quoter?->setTablePrefix($value);

Check failure on line 76 in src/Connection/AbstractConnection.php

View workflow job for this annotation

GitHub Actions / psalm / PHP 8.1-ubuntu-latest

UndefinedInterfaceMethod

src/Connection/AbstractConnection.php:76:25: UndefinedInterfaceMethod: Method Yiisoft\Db\Schema\QuoterInterface::setTablePrefix does not exist (see https://psalm.dev/181)

Check failure on line 76 in src/Connection/AbstractConnection.php

View workflow job for this annotation

GitHub Actions / psalm / PHP 8.1-ubuntu-latest

UndefinedInterfaceMethod

src/Connection/AbstractConnection.php:76:25: UndefinedInterfaceMethod: Method Yiisoft\Db\Schema\QuoterInterface::setTablePrefix does not exist (see https://psalm.dev/181)

Check failure on line 76 in src/Connection/AbstractConnection.php

View workflow job for this annotation

GitHub Actions / psalm / PHP 8.2-ubuntu-latest

UndefinedInterfaceMethod

src/Connection/AbstractConnection.php:76:25: UndefinedInterfaceMethod: Method Yiisoft\Db\Schema\QuoterInterface::setTablePrefix does not exist (see https://psalm.dev/181)
}

public function transaction(Closure $closure, string $isolationLevel = null): mixed
Expand Down
2 changes: 0 additions & 2 deletions src/Driver/Pdo/AbstractPdoConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
use Yiisoft\Db\Profiler\ProfilerAwareInterface;
use Yiisoft\Db\Profiler\ProfilerAwareTrait;
use Yiisoft\Db\QueryBuilder\QueryBuilderInterface;
use Yiisoft\Db\Schema\QuoterInterface;
use Yiisoft\Db\Schema\SchemaInterface;
use Yiisoft\Db\Transaction\TransactionInterface;

Expand All @@ -45,7 +44,6 @@ abstract class AbstractPdoConnection extends AbstractConnection implements PdoCo
protected string $serverVersion = '';
protected bool|null $emulatePrepare = null;
protected QueryBuilderInterface|null $queryBuilder = null;
protected QuoterInterface|null $quoter = null;
protected SchemaInterface|null $schema = null;

public function __construct(protected PdoDriverInterface $driver, protected SchemaCache $schemaCache)
Expand Down
5 changes: 5 additions & 0 deletions src/Schema/Quoter.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,11 @@ public function quoteValue(mixed $value): mixed
return "'" . str_replace("'", "''", addcslashes($value, "\000\032")) . "'";
}

public function setTablePrefix(string $value): void

Check warning on line 218 in src/Schema/Quoter.php

View check run for this annotation

Codecov / codecov/patch

src/Schema/Quoter.php#L218

Added line #L218 was not covered by tests
{
$this->tablePrefix = $value;

Check warning on line 220 in src/Schema/Quoter.php

View check run for this annotation

Codecov / codecov/patch

src/Schema/Quoter.php#L220

Added line #L220 was not covered by tests
}

public function unquoteSimpleColumnName(string $name): string
{
if (is_string($this->columnQuoteCharacter)) {
Expand Down

0 comments on commit 277c97e

Please sign in to comment.