Test Failed
Pull Request — master (#197)
by Wilmer
24:58 queued 18:17
created

DDLQueryBuilder::dropDefaultValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
ccs 3
cts 3
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 509
    }
21
22
    public function addForeignKey(
23
        string $table,
24
        string $name,
25 509
        array|string $columns,
26
        string $refTable,
27
        array|string $refColumns,
28 3
        string $delete = null,
29
        string $update = null
30 3
    ): 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 8
            . ' 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 8
            throw new Exception('Oracle does not support ON UPDATE clause.');
43 8
        }
44 8
45 8
        return $sql;
46 8
    }
47
48 8
    public function alterColumn(string $table, string $column, ColumnInterface|string $type): string
49 3
    {
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 8
            . ' MODIFY '
53 1
            . $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 7
57
    public function checkIntegrity(string $schema = '', string $table = '', bool $check = true): string
58
    {
59 1
        throw new NotSupportedException(__METHOD__ . ' is not supported by Oracle.');
60
    }
61 1
62 1
    public function dropCommentFromColumn(string $table, string $column): string
63 1
    {
64 1
        return 'COMMENT ON COLUMN '
65 1
            . $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 1
            . " IS ''";
69
    }
70 1
71
    public function dropCommentFromTable(string $table): string
72
    {
73 2
        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 2
76 2
    public function dropDefaultValue(string $table, string $name): string
77 2
    {
78 2
        throw new NotSupportedException(__METHOD__ . ' is not supported by Oracle.');
79 2
    }
80
81
    public function dropIndex(string $table, string $name): string
82 2
    {
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 2
    }
85
86
    public function renameTable(string $oldName, string $newName): string
87 2
    {
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 2
            $this->quoter->quoteTableName($newName);
90
    }
91
}
92