Skip to content

Commit

Permalink
Move methods from command to abstract pdo command (#278)
Browse files Browse the repository at this point in the history
* Move methods from `Command` to `AbstractPdoCommand` class

---------

Co-authored-by: StyleCI Bot <[email protected]>
  • Loading branch information
Tigrov and StyleCIBot authored Nov 7, 2023
1 parent 11f981b commit 26eaf4e
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 45 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Enh #263: Support json type (@Tigrov)
- Bug #268: Fix foreign keys: support multiple foreign keys referencing to one table and possible null columns for reference (@Tigrov)
- Bug #271: Refactor `DMLQueryBuilder`, related with yiisoft/db#746 (@Tigrov)
- Enh #278: Move methods from `Command` to `AbstractPdoCommand` class (@Tigrov)

## 1.0.1 July 24, 2023

Expand Down
45 changes: 0 additions & 45 deletions src/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@

namespace Yiisoft\Db\Sqlite;

use PDOException;
use Throwable;
use Yiisoft\Db\Driver\Pdo\AbstractPdoCommand;
use Yiisoft\Db\Exception\ConvertException;
use Yiisoft\Db\Exception\Exception;
use Yiisoft\Db\Exception\InvalidArgumentException;
use Yiisoft\Db\QueryBuilder\QueryBuilderInterface;

use function array_pop;
use function count;
Expand Down Expand Up @@ -60,11 +57,6 @@ public function showDatabases(): array
return $this->setSql($sql)->queryColumn();
}

protected function getQueryBuilder(): QueryBuilderInterface
{
return $this->db->getQueryBuilder();
}

/**
* Executes the SQL statement.
*
Expand Down Expand Up @@ -105,43 +97,6 @@ public function execute(): int
return $result;
}

/**
* @psalm-suppress UnusedClosureParam
*
* @throws Throwable
*/
protected function internalExecute(string|null $rawSql): void
{
$attempt = 0;

while (true) {
try {
if (
++$attempt === 1
&& $this->isolationLevel !== null
&& $this->db->getTransaction() === null
) {
$this->db->transaction(
function () use ($rawSql): void {
$this->internalExecute($rawSql);
},
$this->isolationLevel,
);
} else {
$this->pdoStatement?->execute();
}
break;
} catch (PDOException $e) {
$rawSql = $rawSql ?: $this->getRawSql();
$e = (new ConvertException($e, $rawSql))->run();

if ($this->retryHandler === null || !($this->retryHandler)($e, $attempt)) {
throw $e;
}
}
}
}

/**
* Performs the actual DB query of an SQL statement.
*
Expand Down

0 comments on commit 26eaf4e

Please sign in to comment.