Test Failed
Pull Request — dev (#123)
by Def
11:01 queued 08:38
created

QueryBuilderPDOPgsql::command()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Db\Pgsql\PDO;
6
7
use Yiisoft\Db\Pgsql\DDLQueryBuilder;
8
use Yiisoft\Db\Pgsql\DMLQueryBuilder;
9
use Yiisoft\Db\Pgsql\DQLQueryBuilder;
10
use Yiisoft\Db\Query\QueryBuilder;
0 ignored issues
show
Bug introduced by
The type Yiisoft\Db\Query\QueryBuilder was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use Yiisoft\Db\Schema\QuoterInterface;
12
use Yiisoft\Db\Schema\Schema;
13
use Yiisoft\Db\Schema\SchemaInterface;
14
15
/**
16
 * The class QueryBuilder is the query builder for PostgresSQL databases.
17
 */
18
final class QueryBuilderPDOPgsql extends QueryBuilder
19
{
20
    /**
21
     * Defines a UNIQUE index for {@see createIndex()}.
22
     */
23
    public const INDEX_UNIQUE = 'unique';
24
25
    /**
26
     * Defines a B-tree index for {@see createIndex()}.
27
     */
28
    public const INDEX_B_TREE = 'btree';
29
30
    /**
31
     * Defines a hash index for {@see createIndex()}.
32
     */
33
    public const INDEX_HASH = 'hash';
34
35
    /**
36
     * Defines a GiST index for {@see createIndex()}.
37
     */
38
    public const INDEX_GIST = 'gist';
39
40
    /**
41
     * Defines a GIN index for {@see createIndex()}.
42
     */
43
    public const INDEX_GIN = 'gin';
44
45
    /**
46
     * @var array mapping from abstract column types (keys) to physical column types (values).
47
     *
48
     * @psalm-var string[]
49
     */
50
    protected array $typeMap = [
51
        Schema::TYPE_PK => 'serial NOT NULL PRIMARY KEY',
52
        Schema::TYPE_UPK => 'serial NOT NULL PRIMARY KEY',
53
        Schema::TYPE_BIGPK => 'bigserial NOT NULL PRIMARY KEY',
54
        Schema::TYPE_UBIGPK => 'bigserial NOT NULL PRIMARY KEY',
55
        Schema::TYPE_CHAR => 'char(1)',
56
        Schema::TYPE_STRING => 'varchar(255)',
57
        Schema::TYPE_TEXT => 'text',
58
        Schema::TYPE_TINYINT => 'smallint',
59
        Schema::TYPE_SMALLINT => 'smallint',
60
        Schema::TYPE_INTEGER => 'integer',
61
        Schema::TYPE_BIGINT => 'bigint',
62
        Schema::TYPE_FLOAT => 'double precision',
63
        Schema::TYPE_DOUBLE => 'double precision',
64
        Schema::TYPE_DECIMAL => 'numeric(10,0)',
65
        Schema::TYPE_DATETIME => 'timestamp(0)',
66
        Schema::TYPE_TIMESTAMP => 'timestamp(0)',
67
        Schema::TYPE_TIME => 'time(0)',
68
        Schema::TYPE_DATE => 'date',
69
        Schema::TYPE_BINARY => 'bytea',
70
        Schema::TYPE_BOOLEAN => 'boolean',
71
        Schema::TYPE_MONEY => 'numeric(19,4)',
72
        Schema::TYPE_JSON => 'jsonb',
73
    ];
74
    private DDLQueryBuilder $ddlBuilder;
75
    private DMLQueryBuilder $dmlBuilder;
76
    private DQLQueryBuilder $dqlBuilder;
77
78
    public function __construct(
79
        protected QuoterInterface $quoter,
80
        protected SchemaInterface $schema
81
    ) {
82
        $this->ddlBuilder = new DDLQueryBuilder($this);
83
        $this->dmlBuilder = new DMLQueryBuilder($this);
84
        $this->dqlBuilder = new DQLQueryBuilder($this);
85
        parent::__construct($quoter, $schema, $this->ddlBuilder, $this->dmlBuilder, $this->dqlBuilder);
86
    }
87
}
88