Skip to content

Commit

Permalink
Fixed hasSchema tests & formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
evil1 committed Jan 5, 2025
1 parent 028baf8 commit e42d4b6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## 2.0.0 under development

- Enh #762: Add methods `SchemaInterface::hasSchema()`, `SchemaInterface::hasTable()`, `SchemaInterface::hasView()` (@evil1)
- Enh #820: Support `Traversable` values for `AbstractDMLQueryBuilder::batchInsert()` method with empty columns (@Tigrov)
- Enh #815: Refactor `Query::column()` method (@Tigrov)
- Enh #816: Allow scalar values for `$columns` parameter of `Query::select()` and `Query::addSelect()` methods (@Tigrov)
Expand Down
10 changes: 5 additions & 5 deletions src/Schema/SchemaInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -422,9 +422,9 @@ public function getViewNames(string $schema = '', bool $refresh = false): array;
*
* @param string $tableName The table name to search for
* @param string $schema The schema of the tables. Defaults to empty string, meaning the current or default schema
* name. If not empty, the table will be searched in the specified schema.
* name. If not empty, the table will be searched in the specified schema.
* @param bool $refresh Whether to fetch the latest available table names. If this is false, view names fetched
* before (if available) will be returned.
* before (if available) will be returned.
*
* @return bool Whether table exists.
*/
Expand All @@ -435,7 +435,7 @@ public function hasTable(string $tableName, string $schema = '', bool $refresh =
*
* @param string $schema The schema name to search for
* @param bool $refresh Whether to fetch the latest available schema names. If this is false, view names fetched
* before (if available) will be returned.
* before (if available) will be returned.
*
* @return bool Whether schema exists.
*/
Expand All @@ -446,9 +446,9 @@ public function hasSchema(string $schema, bool $refresh = false): bool;
*
* @param string $viewName The view name to search for
* @param string $schema The schema of the tables. Defaults to empty string, meaning the current or default schema
* name. If not empty, the table will be searched in the specified schema.
* name. If not empty, the table will be searched in the specified schema.
* @param bool $refresh Whether to fetch the latest available view names. If this is false, view names fetched
* before (if available) will be returned.
* before (if available) will be returned.
*
* @return bool Whether view exists.
*/
Expand Down
9 changes: 9 additions & 0 deletions tests/Common/CommonSchemaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,11 @@ public function testHasTable(): void
$this->assertTrue($schema->hasTable('category', '', true));
$this->assertFalse($schema->hasTable('no_such_table', '', true));

if ($db->getDriverName() !== 'sqlite') {
$this->assertFalse($schema->hasTable('customer', 'no_such_schema', true));
$this->assertFalse($schema->hasTable('category', 'no_such_schema', true));
}

$db->close();
}

Expand Down Expand Up @@ -511,6 +516,10 @@ public function testHasView(): void
$this->assertTrue($schema->hasView('animal_view', '', true));
$this->assertFalse($schema->hasView('no_such_view', '', true));

if ($db->getDriverName() !== 'sqlite') {
$this->assertFalse($schema->hasView('animal_view', 'no_such_schema', true));
}

$db->close();
}

Expand Down

0 comments on commit e42d4b6

Please sign in to comment.