Skip to content

Commit 8d29245

Browse files
committed
refactor(dbal): Merge ColumnType and IType
Just make sure ColumnType has a method getName for compatibility purpose Signed-off-by: Carl Schwan <carl@carlschwan.eu>
1 parent 723db4b commit 8d29245

8 files changed

Lines changed: 14 additions & 98 deletions

File tree

lib/composer/composer/autoload_classmap.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,6 @@
377377
'OCP\\DB\\Schema\\IForeignKeyConstraint' => $baseDir . '/lib/public/DB/Schema/IForeignKeyConstraint.php',
378378
'OCP\\DB\\Schema\\IIndex' => $baseDir . '/lib/public/DB/Schema/IIndex.php',
379379
'OCP\\DB\\Schema\\ITable' => $baseDir . '/lib/public/DB/Schema/ITable.php',
380-
'OCP\\DB\\Schema\\IType' => $baseDir . '/lib/public/DB/Schema/IType.php',
381380
'OCP\\DB\\Schema\\SchemaException' => $baseDir . '/lib/public/DB/Schema/SchemaException.php',
382381
'OCP\\DB\\Types' => $baseDir . '/lib/public/DB/Types.php',
383382
'OCP\\Dashboard\\IAPIWidget' => $baseDir . '/lib/public/Dashboard/IAPIWidget.php',
@@ -1790,7 +1789,6 @@
17901789
'OC\\DB\\Schema\\ForeignKeyConstraint' => $baseDir . '/lib/private/DB/Schema/ForeignKeyConstraint.php',
17911790
'OC\\DB\\Schema\\Index' => $baseDir . '/lib/private/DB/Schema/Index.php',
17921791
'OC\\DB\\Schema\\Table' => $baseDir . '/lib/private/DB/Schema/Table.php',
1793-
'OC\\DB\\Schema\\Type' => $baseDir . '/lib/private/DB/Schema/Type.php',
17941792
'OC\\DB\\SetTransactionIsolationLevel' => $baseDir . '/lib/private/DB/SetTransactionIsolationLevel.php',
17951793
'OC\\Dashboard\\Manager' => $baseDir . '/lib/private/Dashboard/Manager.php',
17961794
'OC\\DatabaseException' => $baseDir . '/lib/private/DatabaseException.php',

lib/composer/composer/autoload_static.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,6 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
418418
'OCP\\DB\\Schema\\IForeignKeyConstraint' => __DIR__ . '/../../..' . '/lib/public/DB/Schema/IForeignKeyConstraint.php',
419419
'OCP\\DB\\Schema\\IIndex' => __DIR__ . '/../../..' . '/lib/public/DB/Schema/IIndex.php',
420420
'OCP\\DB\\Schema\\ITable' => __DIR__ . '/../../..' . '/lib/public/DB/Schema/ITable.php',
421-
'OCP\\DB\\Schema\\IType' => __DIR__ . '/../../..' . '/lib/public/DB/Schema/IType.php',
422421
'OCP\\DB\\Schema\\SchemaException' => __DIR__ . '/../../..' . '/lib/public/DB/Schema/SchemaException.php',
423422
'OCP\\DB\\Types' => __DIR__ . '/../../..' . '/lib/public/DB/Types.php',
424423
'OCP\\Dashboard\\IAPIWidget' => __DIR__ . '/../../..' . '/lib/public/Dashboard/IAPIWidget.php',
@@ -1831,7 +1830,6 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
18311830
'OC\\DB\\Schema\\ForeignKeyConstraint' => __DIR__ . '/../../..' . '/lib/private/DB/Schema/ForeignKeyConstraint.php',
18321831
'OC\\DB\\Schema\\Index' => __DIR__ . '/../../..' . '/lib/private/DB/Schema/Index.php',
18331832
'OC\\DB\\Schema\\Table' => __DIR__ . '/../../..' . '/lib/private/DB/Schema/Table.php',
1834-
'OC\\DB\\Schema\\Type' => __DIR__ . '/../../..' . '/lib/private/DB/Schema/Type.php',
18351833
'OC\\DB\\SetTransactionIsolationLevel' => __DIR__ . '/../../..' . '/lib/private/DB/SetTransactionIsolationLevel.php',
18361834
'OC\\Dashboard\\Manager' => __DIR__ . '/../../..' . '/lib/private/Dashboard/Manager.php',
18371835
'OC\\DatabaseException' => __DIR__ . '/../../..' . '/lib/private/DatabaseException.php',

lib/private/DB/Schema/Column.php

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Doctrine\DBAL\Types\Type as DBALType;
1515
use OCP\DB\Schema\ColumnType;
1616
use OCP\DB\Schema\IColumn;
17-
use OCP\DB\Schema\IType;
1817
use OCP\DB\Schema\SchemaException;
1918

2019
/**
@@ -34,11 +33,7 @@ public function getWrappedColumn(): DBALColumn {
3433
}
3534

3635
#[\Override]
37-
public function setType(string|IType|DBALType|ColumnType $type): self {
38-
if ($type instanceof IType) {
39-
$type = $type->getName();
40-
}
41-
36+
public function setType(string|DBALType|ColumnType $type): self {
4237
if ($type instanceof ColumnType) {
4338
$type = $type->value;
4439
}
@@ -98,12 +93,7 @@ public function setDefault(mixed $default): self {
9893
}
9994

10095
#[\Override]
101-
public function getType(): IType {
102-
return new Type($this->column->getType());
103-
}
104-
105-
#[\Override]
106-
public function getColumnType(): ColumnType {
96+
public function getType(): ColumnType {
10797
return ColumnType::from(DBALType::lookupName($this->column->getType()));
10898
}
10999

lib/private/DB/Schema/Type.php

Lines changed: 0 additions & 42 deletions
This file was deleted.

lib/public/DB/Schema/ColumnType.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,4 +163,11 @@ enum ColumnType: string {
163163
* @since 35.0.0
164164
*/
165165
case Json = 'json';
166+
167+
/**
168+
* @since 35.0.0
169+
*/
170+
public function getName(): string {
171+
return $this->value;
172+
}
166173
}

lib/public/DB/Schema/IColumn.php

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
#[Consumable(since: '35.0.0')]
2020
interface IColumn {
2121
/**
22-
* @param \OCP\DB\Types::*|IType|ColumnType $type
22+
* @param \OCP\DB\Types::*|ColumnType $type
2323
* @since 35.0.0
2424
*/
25-
public function setType(string|IType|ColumnType $type): self;
25+
public function setType(string|ColumnType $type): self;
2626

2727
/**
2828
* @since 35.0.0
@@ -62,19 +62,11 @@ public function setDefault(mixed $default): self;
6262
/**
6363
* Returns the type of this column.
6464
*
65-
* Note that {@see IType::getName()} returns a `\OCP\DB\Types::*` value.
65+
* Note that {@see ColumnType::getName()} returns a `\OCP\DB\Types::*` value.
6666
*
6767
* @since 35.0.0
68-
* @note Prefer using getColumnType, this method is here for legacy compatibility.
6968
*/
70-
public function getType(): IType;
71-
72-
/**
73-
* Returns the type of this column.
74-
*
75-
* @since 35.0.0
76-
*/
77-
public function getColumnType(): ColumnType;
69+
public function getType(): ColumnType;
7870

7971
/**
8072
* @return int|null

lib/public/DB/Schema/ITable.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ public function renameIndex(string $oldName, ?string $newName = null): self;
131131
* fixed?: bool,
132132
* precision?: int,
133133
* scale?: int,
134+
* type?: Types::*|ColumnType,
134135
* } $options
135136
*
136137
* @throws SchemaException

lib/public/DB/Schema/IType.php

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)