Skip to content

Commit 3764e69

Browse files
committed
Use search_path
1 parent 30c5db2 commit 3764e69

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/DBAL/Models/PgSQL/PgSQLView.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ protected function handle(DoctrineDBALView $view): void
1616
{
1717
$this->createViewSQL = $this->makeCreateViewSQL($this->quotedName, $view->getSql());
1818

19-
if ($view->getNamespaceName() === DB::connection()->getConfig('schema')) {
19+
$searchPath = DB::connection()->getConfig('search_path') ?: DB::connection()->getConfig('schema');
20+
21+
if ($view->getNamespaceName() === $searchPath) {
2022
// Strip namespace from name.
2123
$name = $view->getShortestName($view->getNamespaceName());
2224
$this->name = $this->makeName($name);

src/DBAL/PgSQLSchema.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ public function getTableNames(): Collection
2828
}
2929

3030
// Schema name defined in the framework configuration.
31-
$schema = DB::connection()->getConfig('schema');
31+
$searchPath = DB::connection()->getConfig('search_path') ?: DB::connection()->getConfig('schema');
3232

3333
$parts = explode('.', $table);
3434
$namespace = $parts[0];
3535

36-
return $namespace === $schema;
36+
return $namespace === $searchPath;
3737
})
3838
->values();
3939
}
@@ -77,7 +77,7 @@ public function getViews(): Collection
7777

7878
// Start from Laravel 9, the `schema` configuration option used to configure Postgres connection search paths renamed to `search_path`.
7979
// Fallback to `schema` if Laravel version is older than 9.
80-
$searchPath = DB::connection()->getConfig('search_path') ?? DB::connection()->getConfig('schema');
80+
$searchPath = DB::connection()->getConfig('search_path') ?: DB::connection()->getConfig('schema');
8181

8282
return $view->getNamespaceName() === $searchPath;
8383
})

0 commit comments

Comments
 (0)