Test Failed
Push — remove-unsed-class ( b4fd4d )
by Wilmer
16:32 queued 09:56
created

DDLQueryBuilder::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 3
dl 0
loc 6
ccs 2
cts 2
cp 1
crap 1
rs 10
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\Exception\Exception;
8
use Yiisoft\Db\Exception\NotSupportedException;
9
use Yiisoft\Db\QueryBuilder\AbstractDDLQueryBuilder;
10
use Yiisoft\Db\Schema\Builder\ColumnInterface;
11
12
/**
13
 * Implements a (Data Definition Language) SQL statements for Oracle Server.
14
 */
15
final class DDLQueryBuilder extends AbstractDDLQueryBuilder
16
{
17
    public function addDefaultValue(string $table, string $name, string $column, mixed $value): string
18
    {
19
        throw new NotSupportedException(__METHOD__ . ' is not supported by Oracle.');
20
    }
21
22
    public function addForeignKey(
23
        string $table,
24
        string $name,
25
        array|string $columns,
26
        string $refTable,
27
        array|string $refColumns,
28
        string $delete = null,
29
        string $update = null
30
    ): string {
31
        $sql = 'ALTER TABLE ' . $this->quoter->quoteTableName($table)
0 ignored issues
show
Bug introduced by
The property quoter is declared private in Yiisoft\Db\QueryBuilder\AbstractDDLQueryBuilder and cannot be accessed from this context.
Loading history...
32
            . ' ADD CONSTRAINT ' . $this->quoter->quoteColumnName($name)
33
            . ' FOREIGN KEY (' . $this->queryBuilder->buildColumns($columns) . ')'
0 ignored issues
show
Bug introduced by
The property queryBuilder is declared private in Yiisoft\Db\QueryBuilder\AbstractDDLQueryBuilder and cannot be accessed from this context.
Loading history...
34
            . ' REFERENCES ' . $this->quoter->quoteTableName($refTable)
35
            . ' (' . $this->queryBuilder->buildColumns($refColumns) . ')';
36
37
        if ($delete !== null) {
38
            $sql .= ' ON DELETE ' . $delete;
39
        }
40
41
        if ($update !== null) {
42
            throw new Exception('Oracle does not support ON UPDATE clause.');
43
        }
44
45
        return $sql;
46
    }
47
48
    public function alterColumn(string $table, string $column, ColumnInterface|string $type): string
49
    {
50
        return 'ALTER TABLE '
51
            . $this->quoter->quoteTableName($table)
0 ignored issues
show
Bug introduced by
The property quoter is declared private in Yiisoft\Db\QueryBuilder\AbstractDDLQueryBuilder and cannot be accessed from this context.
Loading history...
52
            . ' MODIFY '
53
            . $this->quoter->quoteColumnName($column)
54
            . ' ' . $this->queryBuilder->getColumnType($type);
0 ignored issues
show
Bug introduced by
The property queryBuilder is declared private in Yiisoft\Db\QueryBuilder\AbstractDDLQueryBuilder and cannot be accessed from this context.
Loading history...
55
    }
56
57
    public function checkIntegrity(string $schema = '', string $table = '', bool $check = true): string
58
    {
59
        throw new NotSupportedException(__METHOD__ . ' is not supported by Oracle.');
60
    }
61
62
    public function dropCommentFromColumn(string $table, string $column): string
63
    {
64
        return 'COMMENT ON COLUMN '
65
            . $this->quoter->quoteTableName($table)
0 ignored issues
show
Bug introduced by
The property quoter is declared private in Yiisoft\Db\QueryBuilder\AbstractDDLQueryBuilder and cannot be accessed from this context.
Loading history...
66
            . '.'
67
            . $this->quoter->quoteColumnName($column)
68
            . " IS ''";
69
    }
70
71
    public function dropCommentFromTable(string $table): string
72
    {
73
        return 'COMMENT ON TABLE ' . $this->quoter->quoteTableName($table) . " IS ''";
0 ignored issues
show
Bug introduced by
The property quoter is declared private in Yiisoft\Db\QueryBuilder\AbstractDDLQueryBuilder and cannot be accessed from this context.
Loading history...
74
    }
75
76
    public function dropDefaultValue(string $table, string $name): string
77
    {
78
        throw new NotSupportedException(__METHOD__ . ' is not supported by Oracle.');
79
    }
80
81
    public function dropIndex(string $table, string $name): string
82
    {
83
        return 'DROP INDEX ' . $this->quoter->quoteTableName($name);
0 ignored issues
show
Bug introduced by
The property quoter is declared private in Yiisoft\Db\QueryBuilder\AbstractDDLQueryBuilder and cannot be accessed from this context.
Loading history...
84
    }
85
86
    public function renameTable(string $oldName, string $newName): string
87
    {
88
        return 'ALTER TABLE ' . $this->quoter->quoteTableName($oldName) . ' RENAME TO ' .
0 ignored issues
show
Bug introduced by
The property quoter is declared private in Yiisoft\Db\QueryBuilder\AbstractDDLQueryBuilder and cannot be accessed from this context.
Loading history...
89
            $this->quoter->quoteTableName($newName);
90
    }
91
}
92