Passed
Push — dev ( 65e869...962df0 )
by Def
08:15 queued 05:32
created

QueryBuilderPDOPgsql   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 36
c 3
b 0
f 0
dl 0
loc 68
ccs 5
cts 5
cp 1
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
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;
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 414
    public function __construct(
79
        protected QuoterInterface $quoter,
80
        protected SchemaInterface $schema
81
    ) {
82 414
        $this->ddlBuilder = new DDLQueryBuilder($this);
83 414
        $this->dmlBuilder = new DMLQueryBuilder($this);
84 414
        $this->dqlBuilder = new DQLQueryBuilder($this);
85 414
        parent::__construct($quoter, $schema, $this->ddlBuilder, $this->dmlBuilder, $this->dqlBuilder);
86
    }
87
}
88