Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[6.x] Fixed breaking compatability with multi-schema postgres #30562

Merged
merged 6 commits into from
Nov 11, 2019
Merged
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: 4 additions & 4 deletions src/Illuminate/Database/Schema/Grammars/PostgresGrammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,23 +233,23 @@ public function compileDropAllTypes($types)
/**
* Compile the SQL needed to retrieve all table names.
*
* @param string $schema
* @param string|array $schema
* @return string
*/
public function compileGetAllTables($schema)
{
return "select tablename from pg_catalog.pg_tables where schemaname = '{$schema}'";
return "select tablename from pg_catalog.pg_tables where schemaname in ('".implode("','", (array) $schema)."')";
}

/**
* Compile the SQL needed to retrieve all view names.
*
* @param string $schema
* @param string|array $schema
* @return string
*/
public function compileGetAllViews($schema)
{
return "select viewname from pg_catalog.pg_views where schemaname = '{$schema}'";
return "select viewname from pg_catalog.pg_views where schemaname in ('".implode("','", (array) $schema)."')";
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Illuminate/Database/Schema/PostgresBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function dropAllTables()
{
$tables = [];

$excludedTables = ['spatial_ref_sys'];
$excludedTables = $this->connection->getConfig('excluded_drop_tables') ?? ['spatial_ref_sys'];

foreach ($this->getAllTables() as $row) {
$row = (array) $row;
Expand Down Expand Up @@ -105,7 +105,7 @@ public function dropAllTypes()
public function getAllTables()
{
return $this->connection->select(
$this->grammar->compileGetAllTables($this->connection->getConfig('schema'))
$this->grammar->compileGetAllTables((array) $this->connection->getConfig('schema'))
);
}

Expand All @@ -117,7 +117,7 @@ public function getAllTables()
protected function getAllViews()
{
return $this->connection->select(
$this->grammar->compileGetAllViews($this->connection->getConfig('schema'))
$this->grammar->compileGetAllViews((array) $this->connection->getConfig('schema'))
);
}

Expand Down