Skip to content

Commit c0ec3ec

Browse files
authored
Merge pull request #252 from kitloong/feature/pgsql
Get correct constraints by `search_path`
2 parents 8105e4e + 53a583d commit c0ec3ec

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/Repositories/PgSQLRepository.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ class PgSQLRepository extends Repository
1717
*/
1818
public function getCheckConstraintDefinition(string $table, string $column): ?string
1919
{
20+
$searchPath = DB::connection()->getConfig('search_path') ?: DB::connection()->getConfig('schema');
21+
2022
$result = DB::selectOne(
2123
"SELECT pgc.conname AS constraint_name,
2224
pgc.contype,
@@ -31,6 +33,7 @@ public function getCheckConstraintDefinition(string $table, string $column): ?st
3133
ON pgc.conname = ccu.constraint_name
3234
AND nsp.nspname = ccu.constraint_schema
3335
WHERE contype ='c'
36+
AND nsp.nspname = '$searchPath'
3437
AND ccu.table_name='$table'
3538
AND ccu.column_name='$column'",
3639
);

0 commit comments

Comments
 (0)