diff --git a/src/Platforms/PostgreSQL/PostgreSQLMetadataProvider.php b/src/Platforms/PostgreSQL/PostgreSQLMetadataProvider.php index 6b6e91a1928..7dfebac15f0 100644 --- a/src/Platforms/PostgreSQL/PostgreSQLMetadataProvider.php +++ b/src/Platforms/PostgreSQL/PostgreSQLMetadataProvider.php @@ -711,7 +711,7 @@ public function getAllSequences(): iterable private function buildNamespaceNamePredicate(string $columnName): string { - return sprintf("%1\$s NOT LIKE 'pg\_%%' AND %1\$s != 'information_schema'", $columnName); + return sprintf("%1\$s NOT LIKE 'pg\$_%%' ESCAPE '\$' AND %1\$s != 'information_schema'", $columnName); } /** diff --git a/src/Platforms/PostgreSQLPlatform.php b/src/Platforms/PostgreSQLPlatform.php index 34275cff0da..e16b3ba666f 100644 --- a/src/Platforms/PostgreSQLPlatform.php +++ b/src/Platforms/PostgreSQLPlatform.php @@ -165,7 +165,7 @@ public function getListSequencesSQL(string $database): string increment AS increment_by FROM information_schema.sequences WHERE sequence_catalog = ' . $this->quoteStringLiteral($database) . " - AND sequence_schema NOT LIKE 'pg\_%' + AND sequence_schema NOT LIKE 'pg\$_%' ESCAPE '\$' AND sequence_schema != 'information_schema'"; } diff --git a/src/Schema/PostgreSQLSchemaManager.php b/src/Schema/PostgreSQLSchemaManager.php index 10072969f0e..e48ec1ddd05 100644 --- a/src/Schema/PostgreSQLSchemaManager.php +++ b/src/Schema/PostgreSQLSchemaManager.php @@ -42,7 +42,7 @@ public function listSchemaNames(): array <<<'SQL' SELECT schema_name FROM information_schema.schemata -WHERE schema_name NOT LIKE 'pg\_%' +WHERE schema_name NOT LIKE 'pg$_%' ESCAPE '$' AND schema_name != 'information_schema' SQL, ); @@ -338,7 +338,7 @@ protected function selectTableNames(string $databaseName): Result table_schema AS schema_name FROM information_schema.tables WHERE table_catalog = ? - AND table_schema NOT LIKE 'pg\_%' + AND table_schema NOT LIKE 'pg$_%' ESCAPE '$' AND table_schema != 'information_schema' AND table_name != 'geometry_columns' AND table_name != 'spatial_ref_sys' diff --git a/tests/Platforms/PostgreSQLPlatformTest.php b/tests/Platforms/PostgreSQLPlatformTest.php index 19c82f18ac2..da4f2645c6f 100644 --- a/tests/Platforms/PostgreSQLPlatformTest.php +++ b/tests/Platforms/PostgreSQLPlatformTest.php @@ -1006,7 +1006,7 @@ public function testGetListSequencesSQL(): void increment AS increment_by FROM information_schema.sequences WHERE sequence_catalog = 'test_db' - AND sequence_schema NOT LIKE 'pg\_%' + AND sequence_schema NOT LIKE 'pg\$_%' ESCAPE '\$' AND sequence_schema != 'information_schema'", $this->platform->getListSequencesSQL('test_db'), );