Skip to content

Commit

Permalink
Merge pull request #3821 from linniksa/fix-pg-search-path-resolution
Browse files Browse the repository at this point in the history
[pg] fix getting table information if search_path contains escaped schema name
  • Loading branch information
morozov authored Jan 29, 2020
2 parents 4d44646 + eff166f commit a0e2373
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ private function getTableWhereClause($table, $classAlias = 'c', $namespaceAlias
[$schema, $table] = explode('.', $table);
$schema = $this->quoteStringLiteral($schema);
} else {
$schema = "ANY(string_to_array((select replace(replace(setting,'\"\$user\"',user),' ','') from pg_catalog.pg_settings where name = 'search_path'),','))";
$schema = 'ANY(current_schemas(false))';
}

$table = new Identifier($table);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,18 @@ public function testListQuotedTable() : void
self::assertFalse($comparator->diffTable($offlineTable, $onlineTable));
}

public function testListTableDetailsWhenCurrentSchemaNameQuoted() : void
{
$this->connection->exec('CREATE SCHEMA "001_test"');
$this->connection->exec('SET search_path TO "001_test"');

try {
$this->testListQuotedTable();
} finally {
$this->connection->close();
}
}

public function testListTablesExcludesViews() : void
{
$this->createTestTable('list_tables_excludes_views');
Expand Down

0 comments on commit a0e2373

Please sign in to comment.