Commit 0f7df49e authored by Steve Müller's avatar Steve Müller

fix reverse engineering quoted table names on PostgreSQL

parent aa2ed45a
......@@ -21,6 +21,7 @@ namespace Doctrine\DBAL\Platforms;
use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\ColumnDiff;
use Doctrine\DBAL\Schema\Identifier;
use Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\Types\BinaryType;
......@@ -300,6 +301,9 @@ class PostgreSqlPlatform extends AbstractPlatform
*/
public function getListTableConstraintsSQL($table)
{
$table = new Identifier($table);
$table = $table->getName();
return "SELECT
quote_ident(relname) as relname
FROM
......@@ -347,7 +351,9 @@ class PostgreSqlPlatform extends AbstractPlatform
} else {
$schema = "ANY(string_to_array((select replace(replace(setting,'\"\$user\"',user),' ','') from pg_catalog.pg_settings where name = 'search_path'),','))";
}
$whereClause .= "$classAlias.relname = '" . $table . "' AND $namespaceAlias.nspname = $schema";
$table = new Identifier($table);
$whereClause .= "$classAlias.relname = '" . $table->getName() . "' AND $namespaceAlias.nspname = $schema";
return $whereClause;
}
......
......@@ -301,6 +301,24 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
$this->assertInstanceOf('Doctrine\DBAL\Types\BlobType', $table->getColumn('column_binary')->getType());
$this->assertFalse($table->getColumn('column_binary')->getFixed());
}
public function testListQuotedTable()
{
$offlineTable = new Schema\Table('user');
$offlineTable->addColumn('id', 'integer');
$offlineTable->addColumn('username', 'string', array('unique' => true));
$offlineTable->addColumn('fk', 'integer');
$offlineTable->setPrimaryKey(array('id'));
$offlineTable->addForeignKeyConstraint($offlineTable, array('fk'), array('id'));
$this->_sm->dropAndCreateTable($offlineTable);
$onlineTable = $this->_sm->listTableDetails('"user"');
$comparator = new Schema\Comparator();
$this->assertFalse($comparator->diffTable($offlineTable, $onlineTable));
}
}
class MoneyType extends Type
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment