Skip to content

Commit

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

---------

Co-authored-by: StyleCI Bot <bot@styleci.io>
  • Loading branch information
Tigrov and StyleCIBot authored Nov 7, 2023
1 parent cf03e81 commit 675d297
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 47 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- Bug #309: Fix retrieving sequence name from default value (@Tigrov)
- Bug #313: Refactor `DMLQueryBuilder`, related with yiisoft/db#746 (@Tigrov)
- Chg #319: Remove use of abstract type `SchemaInterface::TYPE_JSONB` (@Tigrov)
- Enh #321: Move methods from `Command` to `AbstractPdoCommand` class (@Tigrov)

## 1.1.0 July 24, 2023

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

namespace Yiisoft\Db\Pgsql;

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

/**
* Implements a database command that can be executed with a PDO (PHP Data Object) database connection for PostgreSQL
Expand All @@ -24,47 +20,4 @@ public function showDatabases(): array

return $this->setSql($sql)->queryColumn();
}

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

/**
* @psalm-suppress UnusedClosureParam
*
* @throws \Yiisoft\Db\Exception\Exception
* @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 (Exception $e) {
$rawSql = $rawSql ?: $this->getRawSql();
$e = (new ConvertException($e, $rawSql))->run();

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

0 comments on commit 675d297

Please sign in to comment.