Commit ecbfc68d authored by Marius Meißner's avatar Marius Meißner Committed by Steve Müller

DBAL-#2517: Fixed ORA-01427 when listing columns

parent a526d0df
...@@ -655,25 +655,27 @@ LEFT JOIN user_cons_columns r_cols ...@@ -655,25 +655,27 @@ LEFT JOIN user_cons_columns r_cols
$tabColumnsTableName = "user_tab_columns"; $tabColumnsTableName = "user_tab_columns";
$colCommentsTableName = "user_col_comments"; $colCommentsTableName = "user_col_comments";
$ownerCondition = ''; $tabColumnsOwnerCondition = '';
$colCommentsOwnerCondition = '';
if (null !== $database && '/' !== $database) { if (null !== $database && '/' !== $database) {
$database = $this->normalizeIdentifier($database); $database = $this->normalizeIdentifier($database);
$database = $this->quoteStringLiteral($database->getName()); $database = $this->quoteStringLiteral($database->getName());
$tabColumnsTableName = "all_tab_columns"; $tabColumnsTableName = "all_tab_columns";
$colCommentsTableName = "all_col_comments"; $colCommentsTableName = "all_col_comments";
$ownerCondition = "AND c.owner = " . $database; $tabColumnsOwnerCondition = "AND c.owner = " . $database;
$colCommentsOwnerCondition = "AND d.OWNER = c.OWNER";
} }
return "SELECT c.*, return "SELECT c.*,
( (
SELECT d.comments SELECT d.comments
FROM $colCommentsTableName d FROM $colCommentsTableName d
WHERE d.TABLE_NAME = c.TABLE_NAME WHERE d.TABLE_NAME = c.TABLE_NAME " . $colCommentsOwnerCondition . "
AND d.COLUMN_NAME = c.COLUMN_NAME AND d.COLUMN_NAME = c.COLUMN_NAME
) AS comments ) AS comments
FROM $tabColumnsTableName c FROM $tabColumnsTableName c
WHERE c.table_name = " . $table . " $ownerCondition WHERE c.table_name = " . $table . " $tabColumnsOwnerCondition
ORDER BY c.column_name"; ORDER BY c.column_name";
} }
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
namespace Doctrine\Tests\DBAL\Functional\Schema; namespace Doctrine\Tests\DBAL\Functional\Schema;
use Doctrine\DBAL\Schema; use Doctrine\DBAL\Schema;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\TestUtil; use Doctrine\Tests\TestUtil;
require_once __DIR__ . '/../../../TestInit.php'; require_once __DIR__ . '/../../../TestInit.php';
...@@ -218,4 +220,17 @@ class OracleSchemaManagerTest extends SchemaManagerFunctionalTestCase ...@@ -218,4 +220,17 @@ class OracleSchemaManagerTest extends SchemaManagerFunctionalTestCase
$onlineForeignTable->getForeignKey('"Primary_Table_Fk"')->getQuotedForeignColumns($platform) $onlineForeignTable->getForeignKey('"Primary_Table_Fk"')->getQuotedForeignColumns($platform)
); );
} }
public function testListTableColumnsSameTableNamesInDifferentSchemas()
{
$table = $this->createListTableColumns();
$this->_sm->dropAndCreateTable($table);
$otherTable = new Table($table->getName());
$otherTable->addColumn('id', Type::STRING);
TestUtil::getTempConnection()->getSchemaManager()->dropAndCreateTable($otherTable);
$columns = $this->_sm->listTableColumns($table->getName(), $this->_conn->getUsername());
$this->assertCount(7, $columns);
}
} }
...@@ -727,7 +727,7 @@ EOD; ...@@ -727,7 +727,7 @@ EOD;
( (
SELECT d.comments SELECT d.comments
FROM user_col_comments d FROM user_col_comments d
WHERE d.TABLE_NAME = c.TABLE_NAME WHERE d.TABLE_NAME = c.TABLE_NAME
AND d.COLUMN_NAME = c.COLUMN_NAME AND d.COLUMN_NAME = c.COLUMN_NAME
) AS comments ) AS comments
FROM user_tab_columns c FROM user_tab_columns c
...@@ -740,7 +740,7 @@ EOD; ...@@ -740,7 +740,7 @@ EOD;
( (
SELECT d.comments SELECT d.comments
FROM user_col_comments d FROM user_col_comments d
WHERE d.TABLE_NAME = c.TABLE_NAME WHERE d.TABLE_NAME = c.TABLE_NAME
AND d.COLUMN_NAME = c.COLUMN_NAME AND d.COLUMN_NAME = c.COLUMN_NAME
) AS comments ) AS comments
FROM user_tab_columns c FROM user_tab_columns c
...@@ -753,7 +753,7 @@ EOD; ...@@ -753,7 +753,7 @@ EOD;
( (
SELECT d.comments SELECT d.comments
FROM all_col_comments d FROM all_col_comments d
WHERE d.TABLE_NAME = c.TABLE_NAME WHERE d.TABLE_NAME = c.TABLE_NAME AND d.OWNER = c.OWNER
AND d.COLUMN_NAME = c.COLUMN_NAME AND d.COLUMN_NAME = c.COLUMN_NAME
) AS comments ) AS comments
FROM all_tab_columns c FROM all_tab_columns c
......
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