diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f488b79a..a5f9bd28e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/src/Schema/SchemaInterface.php b/src/Schema/SchemaInterface.php index febf59045..ca64365e9 100644 --- a/src/Schema/SchemaInterface.php +++ b/src/Schema/SchemaInterface.php @@ -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. */ @@ -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. */ @@ -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. */ diff --git a/tests/Common/CommonSchemaTest.php b/tests/Common/CommonSchemaTest.php index a91ec4f69..1c321da3b 100644 --- a/tests/Common/CommonSchemaTest.php +++ b/tests/Common/CommonSchemaTest.php @@ -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(); } @@ -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(); }