Skip to content
Open
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
8 changes: 5 additions & 3 deletions lib/private/DB/Schema/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Doctrine\DBAL\Schema\SchemaException as DBALSchemaException;
use Doctrine\DBAL\Schema\Table as DBALTable;
use Doctrine\DBAL\Types\Type as DBALType;
use OC\DB\Connection;
use OCP\DB\Schema\ColumnType;
use OCP\DB\Schema\IColumn;
use OCP\DB\Schema\IForeignKeyConstraint;
Expand All @@ -27,7 +28,8 @@
*/
class Table implements ITable {
public function __construct(
private DBALTable $table,
private readonly DBALTable $table,
private readonly Connection $connection,
) {
}

Expand Down Expand Up @@ -117,7 +119,7 @@ public function getPrimaryKey(): ?IIndex {

#[\Override]
public function hasPrimaryKey(): bool {
return $this->table->hasPrimaryKey();
return $this->table->getPrimaryKey() !== null;
}

#[\Override]
Expand Down Expand Up @@ -206,7 +208,7 @@ public function addForeignKeyConstraint(
): self {
try {
$this->table->addForeignKeyConstraint(
$foreignTable instanceof self ? $foreignTable->getWrappedTable() : $foreignTable,
$foreignTable instanceof self ? $foreignTable->getWrappedTable() : $this->connection->getPrefix() . $foreignTable,
$localColumnNames,
$foreignColumnNames,
$options,
Expand Down
4 changes: 2 additions & 2 deletions lib/private/DB/SchemaWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
#[\Override]
public function getTable(string $tableName): ITable {
try {
return new Table($this->schema->getTable($this->connection->getPrefix() . $tableName));
return new Table($this->schema->getTable($this->connection->getPrefix() . $tableName), $this->connection);
} catch (DBALSchemaException $e) {
throw new SchemaException($e->getMessage(), $e->getCode(), $e);
}
Expand All @@ -93,7 +93,7 @@
public function createTable(string $tableName): ITable {
unset($this->tablesToDelete[$tableName]);
try {
return new Table($this->schema->createTable($this->connection->getPrefix() . $tableName));
return new Table($this->schema->createTable($this->connection->getPrefix() . $tableName), $this->connection);
} catch (DBALSchemaException $e) {
throw new SchemaException($e->getMessage(), $e->getCode(), $e);
}
Expand All @@ -108,7 +108,7 @@

#[\Override]
public function getTables(): array {
return array_values(array_map(fn (DBALTable $table): ITable => new Table($table), $this->schema->getTables()));

Check failure on line 111 in lib/private/DB/SchemaWrapper.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

TooFewArguments

lib/private/DB/SchemaWrapper.php:111:66: TooFewArguments: Too few arguments for OC\DB\Schema\Table::__construct - expecting connection to be passed (see https://psalm.dev/025)
}

#[\Override]
Expand Down
Loading