Skip to content

Commit

Permalink
Fix issue yiisoft#762
Browse files Browse the repository at this point in the history
  • Loading branch information
evil1 committed Dec 25, 2024
1 parent fd253ea commit 966e214
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
12 changes: 6 additions & 6 deletions src/Schema/AbstractSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -578,29 +578,29 @@ public function getViewNames(string $schema = '', bool $refresh = false): array
/**
* @throws Throwable
*/
public function hasTable(string $tableName, string $schema = ''): bool
public function hasTable(string $tableName, string $schema = '', bool $refresh = false): bool
{
$tables = $this->getTableNames($schema);
$tables = $this->getTableNames($schema, $refresh);

return in_array($tableName, $tables);
}

/**
* @throws Throwable
*/
public function hasSchema(string $schema): bool
public function hasSchema(string $schema, bool $refresh = false): bool
{
$schemas = $this->getSchemaNames();
$schemas = $this->getSchemaNames($refresh);

return in_array($schema, $schemas);
}

/**
* @throws Throwable
*/
public function hasView(string $viewName, string $schema = ''): bool
public function hasView(string $viewName, string $schema = '', bool $refresh = false): bool
{
$views = $this->getViewNames($schema);
$views = $this->getViewNames($schema, $refresh);

return in_array($viewName, $views);
}
Expand Down
15 changes: 12 additions & 3 deletions src/Schema/SchemaInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -423,25 +423,34 @@ 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.
* @param bool $refresh Whether to fetch the latest available table names. If this is false, view names fetched
* before (if available) will be returned.
*
* @return bool Whether table exists or not
*/
public function hasTable(string $tableName, string $schema = ''): bool;
public function hasTable(string $tableName, string $schema = '', bool $refresh = false): bool;

/**
* Determines if a specified schema exists in the database.
*
* @param string $schema The table 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.
*
* @return bool Whether schema exists or not
*/
public function hasSchema(string $schema): bool;
public function hasSchema(string $schema, bool $refresh = false): bool;

/**
* Determines if a specified view exists in the database.
*
* @param string $viewName 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.
* @param bool $refresh Whether to fetch the latest available view names. If this is false, view names fetched
* before (if available) will be returned.
*
* @return bool Whether view exists or not
*/
public function hasView(string $viewName, string $schema = ''): bool;
public function hasView(string $viewName, string $schema = '', bool $refresh = false): bool;
}

0 comments on commit 966e214

Please sign in to comment.