Skip to content

Commit a8cc099

Browse files
Use prefix Abstract in abstract class querybuilder. (#176)
* Use prefix Abstract in abstract class querybuilder.
1 parent b3e2ff5 commit a8cc099

7 files changed

Lines changed: 39 additions & 20 deletions

File tree

src/ColumnSchemaBuilder.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44

55
namespace Yiisoft\Db\Sqlite;
66

7+
use Stringable;
78
use Yiisoft\Db\Schema\ColumnSchemaBuilder as AbstractColumnSchemaBuilder;
89

9-
final class ColumnSchemaBuilder extends AbstractColumnSchemaBuilder implements \Stringable
10+
final class ColumnSchemaBuilder extends AbstractColumnSchemaBuilder implements Stringable
1011
{
1112
/**
1213
* Builds the unsigned string for column. Defaults to unsupported.

src/DDLQueryBuilder.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use Yiisoft\Db\Exception\Exception;
88
use Yiisoft\Db\Exception\InvalidArgumentException;
99
use Yiisoft\Db\Exception\NotSupportedException;
10-
use Yiisoft\Db\QueryBuilder\DDLQueryBuilder as AbstractDDLQueryBuilder;
10+
use Yiisoft\Db\QueryBuilder\AbstractDDLQueryBuilder;
1111
use Yiisoft\Db\QueryBuilder\QueryBuilderInterface;
1212
use Yiisoft\Db\Schema\ColumnSchemaBuilder;
1313
use Yiisoft\Db\Schema\QuoterInterface;
@@ -102,7 +102,8 @@ public function checkIntegrity(string $schema = '', string $table = '', bool $ch
102102
}
103103

104104
/**
105-
* @throws Exception|InvalidArgumentException
105+
* @throws Exception
106+
* @throws InvalidArgumentException
106107
*/
107108
public function createIndex(
108109
string $name,

src/DMLQueryBuilder.php

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
use Yiisoft\Db\Exception\NotSupportedException;
1414
use Yiisoft\Db\Expression\Expression;
1515
use Yiisoft\Db\Expression\ExpressionInterface;
16-
use Yiisoft\Db\QueryBuilder\DMLQueryBuilder as AbstractDMLQueryBuilder;
17-
use Yiisoft\Db\QueryBuilder\QueryBuilderInterface;
1816
use Yiisoft\Db\Query\QueryInterface;
17+
use Yiisoft\Db\QueryBuilder\AbstractDMLQueryBuilder;
18+
use Yiisoft\Db\QueryBuilder\QueryBuilderInterface;
1919
use Yiisoft\Db\Schema\QuoterInterface;
2020
use Yiisoft\Db\Schema\SchemaInterface;
2121

@@ -34,7 +34,19 @@ public function __construct(
3434
}
3535

3636
/**
37-
* @throws Exception|Throwable
37+
* @throws Exception
38+
* @throws InvalidArgumentException
39+
* @throws InvalidConfigException
40+
* @throws NotSupportedException
41+
*/
42+
public function insertWithReturningPks(string $table, QueryInterface|array $columns, array &$params = []): string
43+
{
44+
throw new NotSupportedException(__METHOD__ . '() is not supported by SQLite.');
45+
}
46+
47+
/**
48+
* @throws Exception
49+
* @throws Throwable
3850
*/
3951
public function resetSequence(string $tableName, int|string $value = null): string
4052
{
@@ -64,15 +76,19 @@ public function resetSequence(string $tableName, int|string $value = null): stri
6476
}
6577

6678
/**
67-
* @throws Exception|InvalidArgumentException|InvalidConfigException|JsonException|NotSupportedException
79+
* @throws Exception
80+
* @throws InvalidArgumentException
81+
* @throws InvalidConfigException
82+
* @throws JsonException
83+
* @throws NotSupportedException
6884
*/
6985
public function upsert(
7086
string $table,
7187
QueryInterface|array $insertColumns,
7288
bool|array $updateColumns,
7389
array &$params
7490
): string {
75-
/** @var Constraint[] $constraints */
91+
/** @psalm-var Constraint[] $constraints */
7692
$constraints = [];
7793

7894
/**
@@ -91,9 +107,7 @@ public function upsert(
91107
return $this->insert($table, $insertColumns, $params);
92108
}
93109

94-
/**
95-
* @psalm-var string[] $placeholders
96-
*/
110+
/** @psalm-var string[] $placeholders */
97111
[, $placeholders, $values, $params] = $this->prepareInsertValues($table, $insertColumns, $params);
98112

99113
$insertSql = 'INSERT OR IGNORE INTO '
@@ -110,7 +124,7 @@ public function upsert(
110124

111125
foreach ($constraints as $constraint) {
112126
$constraintCondition = ['and'];
113-
/** @psalm-var string[] */
127+
/** @psalm-var string[] $columnsNames */
114128
$columnsNames = $constraint->getColumnNames();
115129
foreach ($columnsNames as $name) {
116130
$quotedName = $this->quoter->quoteColumnName($name);
@@ -135,7 +149,7 @@ public function upsert(
135149
return $insertSql;
136150
}
137151

138-
/** @var array $params */
152+
/** @psalm-var array $params */
139153
$updateSql = 'WITH "EXCLUDED" ('
140154
. implode(', ', $insertNames)
141155
. ') AS (' . (!empty($placeholders)

src/DQLQueryBuilder.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
use Yiisoft\Db\Expression\Expression;
88
use Yiisoft\Db\Expression\ExpressionBuilderInterface;
99
use Yiisoft\Db\Expression\ExpressionInterface;
10-
use Yiisoft\Db\QueryBuilder\DQLQueryBuilder as AbstractDQLQueryBuilder;
11-
use Yiisoft\Db\QueryBuilder\QueryBuilderInterface;
12-
use Yiisoft\Db\QueryBuilder\Condition\InCondition;
13-
use Yiisoft\Db\QueryBuilder\Condition\LikeCondition;
1410
use Yiisoft\Db\Query\Query;
1511
use Yiisoft\Db\Query\QueryInterface;
12+
use Yiisoft\Db\QueryBuilder\AbstractDQLQueryBuilder;
13+
use Yiisoft\Db\QueryBuilder\Condition\InCondition;
14+
use Yiisoft\Db\QueryBuilder\Condition\LikeCondition;
15+
use Yiisoft\Db\QueryBuilder\QueryBuilderInterface;
1616
use Yiisoft\Db\Schema\QuoterInterface;
1717
use Yiisoft\Db\Schema\SchemaInterface;
1818
use Yiisoft\Db\Sqlite\Builder\InConditionBuilder;

src/QueryBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Yiisoft\Db\Sqlite;
66

7-
use Yiisoft\Db\QueryBuilder\QueryBuilder as AbstractQueryBuilder;
7+
use Yiisoft\Db\QueryBuilder\AbstractQueryBuilder;
88
use Yiisoft\Db\Schema\QuoterInterface;
99
use Yiisoft\Db\Schema\Schema;
1010
use Yiisoft\Db\Schema\SchemaInterface;

src/SqlToken.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Yiisoft\Db\Sqlite;
66

77
use ArrayAccess;
8+
use Stringable;
89

910
use function array_splice;
1011
use function count;
@@ -22,7 +23,7 @@
2223
* read-only.
2324
* @property string $sql SQL code. This property is read-only.
2425
*/
25-
final class SqlToken implements ArrayAccess, \Stringable
26+
final class SqlToken implements ArrayAccess, Stringable
2627
{
2728
public const TYPE_CODE = 0;
2829
public const TYPE_STATEMENT = 1;

tests/QueryBuilderTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,9 @@ public function testInsertWithReturningPks(
586586
array $expectedParams
587587
): void {
588588
$this->expectException(NotSupportedException::class);
589-
$this->expectExceptionMessage('Yiisoft\Db\QueryBuilder\DMLQueryBuilder::insertWithReturningPks() is not supported by this DBMS.');
589+
$this->expectExceptionMessage(
590+
'Yiisoft\Db\Sqlite\DMLQueryBuilder::insertWithReturningPks() is not supported by SQLite.'
591+
);
590592

591593
$db = $this->getConnection(true);
592594
$qb = $db->getQueryBuilder();

0 commit comments

Comments
 (0)