Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/private/DB/Schema/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
5 changes: 5 additions & 0 deletions lib/private/DB/Schema/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
6 changes: 3 additions & 3 deletions lib/public/AppFramework/Db/SnowflakeAwareEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -24,8 +24,8 @@
abstract class SnowflakeAwareEntity extends Entity {
protected ?Snowflake $snowflake = null;

/** @psalm-param $_fieldTypes array<string, Types::*> */
protected array $_fieldTypes = ['id' => Types::STRING];
/** @psalm-param $_fieldTypes array<string, ColumnType> */
protected array $_fieldTypes = ['id' => ColumnType::String];

/**
* @since 33.0.0
Expand Down
1 change: 1 addition & 0 deletions lib/public/DB/Schema/IIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ interface IIndex {
/**
* Returns the name of this index.
*
* @return non-empty-string
* @since 35.0.0
*/
public function getName(): string;
Expand Down
24 changes: 17 additions & 7 deletions lib/public/DB/Schema/ITable.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function getName(): string;
* Sets the Primary Key.
*
* @param list<non-empty-string> $columnNames
* @param string|false $indexName
* @param non-empty-string|false $indexName
*
* @throws SchemaException
* @since 35.0.0
Expand All @@ -40,6 +40,7 @@ public function setPrimaryKey(array $columnNames, string|false $indexName = fals

/**
* @param list<non-empty-lowercase-string> $columnNames
* @param ?non-empty-string $indexName
* @param list<non-empty-lowercase-string> $flags
* @param array<non-empty-lowercase-string, mixed> $options
*
Expand Down Expand Up @@ -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
Expand All @@ -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<string> $columnNames
* @param string|null $indexName
* @param non-empty-string|null $indexName
* @param array<string, mixed> $options
*
* @throws SchemaException
Expand All @@ -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.
*
Expand Down Expand Up @@ -200,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.
*
Expand Down
Loading