Passed
Push — master ( c77b03...911b01 )
by Alexander
32:33 queued 12:30
created

QueryBuilder::executeResetSequence()   A

Complexity

Conditions 5
Paths 5

Size

Total Lines 40
Code Lines 23

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 19
CRAP Score 5.1314

Importance

Changes 0
Metric Value
cc 5
eloc 23
nc 5
nop 2
dl 0
loc 40
ccs 19
cts 23
cp 0.8261
crap 5.1314
rs 9.2408
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Db\Oracle;
6
7
use Yiisoft\Db\QueryBuilder\QueryBuilder as AbstractQueryBuilder;
8
use Yiisoft\Db\Schema\QuoterInterface;
9
use Yiisoft\Db\Schema\Schema;
0 ignored issues
show
Bug introduced by
This use statement conflicts with another class in this namespace, Yiisoft\Db\Oracle\Schema. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
10
use Yiisoft\Db\Schema\SchemaInterface;
11
12
/**
13
 * QueryBuilder is the query builder for Oracle databases.
14
 */
15
final class QueryBuilder extends AbstractQueryBuilder
16
{
17
    /**
18
     * Defines a BITMAP index type for {@see createIndex()}.
19
     */
20
    public const INDEX_BITMAP = 'BITMAP';
21
22
    /**
23
     * @psalm-var string[] $typeMap Mapping from abstract column types (keys) to physical column types (values).
24
     */
25
    protected array $typeMap = [
26
        Schema::TYPE_PK => 'NUMBER(10) NOT NULL PRIMARY KEY',
27
        Schema::TYPE_UPK => 'NUMBER(10) UNSIGNED NOT NULL PRIMARY KEY',
28
        Schema::TYPE_BIGPK => 'NUMBER(20) NOT NULL PRIMARY KEY',
29
        Schema::TYPE_UBIGPK => 'NUMBER(20) UNSIGNED NOT NULL PRIMARY KEY',
30
        Schema::TYPE_CHAR => 'CHAR(1)',
31
        Schema::TYPE_STRING => 'VARCHAR2(255)',
32
        Schema::TYPE_TEXT => 'CLOB',
33
        Schema::TYPE_TINYINT => 'NUMBER(3)',
34
        Schema::TYPE_SMALLINT => 'NUMBER(5)',
35
        Schema::TYPE_INTEGER => 'NUMBER(10)',
36
        Schema::TYPE_BIGINT => 'NUMBER(20)',
37
        Schema::TYPE_FLOAT => 'NUMBER',
38
        Schema::TYPE_DOUBLE => 'NUMBER',
39
        Schema::TYPE_DECIMAL => 'NUMBER',
40
        Schema::TYPE_DATETIME => 'TIMESTAMP',
41
        Schema::TYPE_TIMESTAMP => 'TIMESTAMP',
42
        Schema::TYPE_TIME => 'TIMESTAMP',
43
        Schema::TYPE_DATE => 'DATE',
44
        Schema::TYPE_BINARY => 'BLOB',
45
        Schema::TYPE_BOOLEAN => 'NUMBER(1)',
46
        Schema::TYPE_MONEY => 'NUMBER(19,4)',
47
    ];
48
    private DDLQueryBuilder $ddlBuilder;
49
    private DMLQueryBuilder $dmlBuilder;
50
    private DQLQueryBuilder $dqlBuilder;
51
52 345
    public function __construct(QuoterInterface $quoter, SchemaInterface $schema)
53
    {
54 345
        $this->ddlBuilder = new DDLQueryBuilder($this, $quoter, $schema);
55 345
        $this->dmlBuilder = new DMLQueryBuilder($this, $quoter, $schema);
56 345
        $this->dqlBuilder = new DQLQueryBuilder($this, $quoter, $schema);
57 345
        parent::__construct($quoter, $schema, $this->ddlBuilder, $this->dmlBuilder, $this->dqlBuilder);
58
    }
59
}
60