Skip to content

Commit

Permalink
Add setter for defaultSchema propierty.
Browse files Browse the repository at this point in the history
  • Loading branch information
terabytesoftw committed Aug 15, 2023
1 parent b047dae commit 64aaf0c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Schema/AbstractSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ abstract protected function loadTableUniques(string $tableName): array;
*/
abstract protected function loadTableSchema(string $name): TableSchemaInterface|null;

public function defaultSchema(string $defaultSchema): void

Check warning on line 129 in src/Schema/AbstractSchema.php

View check run for this annotation

Codecov / codecov/patch

src/Schema/AbstractSchema.php#L129

Added line #L129 was not covered by tests
{
$this->defaultSchema = $defaultSchema;

Check warning on line 131 in src/Schema/AbstractSchema.php

View check run for this annotation

Codecov / codecov/patch

src/Schema/AbstractSchema.php#L131

Added line #L131 was not covered by tests
}

public function getDefaultSchema(): string|null
{
return $this->defaultSchema;
Expand Down
7 changes: 7 additions & 0 deletions src/Schema/SchemaInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -404,4 +404,11 @@ public function enableCache(bool $value): void;
* @return array All view names in the database.
*/
public function getViewNames(string $schema = '', bool $refresh = false): array;

/**
* Set the default schema of the database.
*
* @param string $defaultSchema The default schema name.
*/
public function defaultSchema(string $defaultSchema): void;
}
10 changes: 10 additions & 0 deletions tests/Db/Schema/SchemaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,16 @@ public function testSetTableMetadata(): void
$this->assertSame($checkConstraint, $schema->getTableChecks('T_constraints_1'));
}

public function testDefaultSchema(): void
{
$db = $this->getConnection();

$schema = $db->getSchema();
$schema->defaultSchema('yii');

$this->assertSame('yii', $schema->getDefaultSchema());
}

private function createTableSchemaStub(): TableSchemaInterface
{
// defined column C_id
Expand Down

0 comments on commit 64aaf0c

Please sign in to comment.