From 343c563d672a2e0fbc125f8f57e1882efa8d3d1f Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Wed, 12 Aug 2026 11:13:16 +0200 Subject: [PATCH 1/3] refactor(dbal): Adjust types of some strings Signed-off-by: Carl Schwan --- lib/private/DB/Schema/Index.php | 4 +++- lib/public/DB/Schema/IIndex.php | 1 + lib/public/DB/Schema/ITable.php | 15 ++++++++------- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/private/DB/Schema/Index.php b/lib/private/DB/Schema/Index.php index 37a613c0d0dc1..82c9538b6681c 100644 --- a/lib/private/DB/Schema/Index.php +++ b/lib/private/DB/Schema/Index.php @@ -30,7 +30,9 @@ public function getWrappedIndex(): DBALIndex { #[\Override] public function getName(): string { - return $this->index->getName(); + /** @var non-empty-string $name */ + $name = $this->index->getName(); + return $name; } #[\Override] diff --git a/lib/public/DB/Schema/IIndex.php b/lib/public/DB/Schema/IIndex.php index 745cca67c08c0..af2ca8309ef28 100644 --- a/lib/public/DB/Schema/IIndex.php +++ b/lib/public/DB/Schema/IIndex.php @@ -21,6 +21,7 @@ interface IIndex { /** * Returns the name of this index. * + * @return non-empty-string * @since 35.0.0 */ public function getName(): string; diff --git a/lib/public/DB/Schema/ITable.php b/lib/public/DB/Schema/ITable.php index 12f762c799517..e6cde299f8168 100644 --- a/lib/public/DB/Schema/ITable.php +++ b/lib/public/DB/Schema/ITable.php @@ -31,7 +31,7 @@ public function getName(): string; * Sets the Primary Key. * * @param list $columnNames - * @param string|false $indexName + * @param non-empty-string|false $indexName * * @throws SchemaException * @since 35.0.0 @@ -40,6 +40,7 @@ public function setPrimaryKey(array $columnNames, string|false $indexName = fals /** * @param list $columnNames + * @param ?non-empty-string $indexName * @param list $flags * @param array $options * @@ -79,7 +80,7 @@ public function getPrimaryKey(): ?IIndex; /** * Drops an index from this table. * - * @param non-empty-lowercase-string $name The index name. + * @param non-empty-string $name The index name. * * @throws SchemaException If the index does not exist. * @since 35.0.0 @@ -89,14 +90,14 @@ public function dropIndex(string $name): self; /** * Returns whether this table has an index with the given name. * - * @param non-empty-lowercase-string $name The index name. + * @param non-empty-string $name The index name. * @since 35.0.0 */ public function hasIndex(string $name): bool; /** * @param list $columnNames - * @param string|null $indexName + * @param non-empty-string|null $indexName * @param array $options * * @throws SchemaException @@ -107,9 +108,9 @@ public function addUniqueIndex(array $columnNames, ?string $indexName = null, ar /** * Renames an index. * - * @param non-empty-lowercase-string $oldName The name of the index to rename from. - * @param non-empty-lowercase-string|null $newName The name of the index to rename to. - * If null is given, the index name will be auto-generated. + * @param non-empty-string $oldName The name of the index to rename from. + * @param non-empty-string|null $newName The name of the index to rename to. + * If null is given, the index name will be auto-generated. * * @return self This table instance. * From 7bf08871dd0e2bc857adae7fe3bdd240fa8db645 Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Wed, 12 Aug 2026 11:15:24 +0200 Subject: [PATCH 2/3] fix(entity): Use ColumnType also in SnowflakeAwareEntity Signed-off-by: Carl Schwan --- lib/public/AppFramework/Db/SnowflakeAwareEntity.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/public/AppFramework/Db/SnowflakeAwareEntity.php b/lib/public/AppFramework/Db/SnowflakeAwareEntity.php index 5f68708a6caf8..ab5ea1fd246a6 100644 --- a/lib/public/AppFramework/Db/SnowflakeAwareEntity.php +++ b/lib/public/AppFramework/Db/SnowflakeAwareEntity.php @@ -9,7 +9,7 @@ namespace OCP\AppFramework\Db; use OCP\AppFramework\Attribute\Consumable; -use OCP\DB\Types; +use OCP\DB\Schema\ColumnType; use OCP\Server; use OCP\Snowflake\ISnowflakeDecoder; use OCP\Snowflake\ISnowflakeGenerator; @@ -24,8 +24,8 @@ abstract class SnowflakeAwareEntity extends Entity { protected ?Snowflake $snowflake = null; - /** @psalm-param $_fieldTypes array */ - protected array $_fieldTypes = ['id' => Types::STRING]; + /** @psalm-param $_fieldTypes array */ + protected array $_fieldTypes = ['id' => ColumnType::String]; /** * @since 33.0.0 From 78d33182a01bb4da4d3d8afc6fcaa1b29fcd44c7 Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Wed, 12 Aug 2026 12:07:33 +0200 Subject: [PATCH 3/3] feat(dbal): Add ITable::getIndex Signed-off-by: Carl Schwan --- lib/private/DB/Schema/Table.php | 5 +++++ lib/public/DB/Schema/ITable.php | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/lib/private/DB/Schema/Table.php b/lib/private/DB/Schema/Table.php index 7f3e6db8015c7..d8b99cfa5ce65 100644 --- a/lib/private/DB/Schema/Table.php +++ b/lib/private/DB/Schema/Table.php @@ -256,6 +256,11 @@ public function getIndexes(): array { )); } + #[\Override] + public function getIndex(string $name): IIndex { + return new Index($this->table->getIndex($name)); + } + #[\Override] public function getForeignKeys(): array { return array_values(array_map( diff --git a/lib/public/DB/Schema/ITable.php b/lib/public/DB/Schema/ITable.php index e6cde299f8168..35311b0269062 100644 --- a/lib/public/DB/Schema/ITable.php +++ b/lib/public/DB/Schema/ITable.php @@ -201,6 +201,15 @@ public function getColumns(): array; */ public function getIndexes(): array; + /** + * Returns a specific index by name of this table. + * + * @param non-empty-string $name The index name. + * @return IIndex + * @since 35.0.0 + */ + public function getIndex(string $name): IIndex; + /** * Adds a foreign key constraint. *