Commit c60295f9 authored by Marius Meißner's avatar Marius Meißner

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

parent ec8fc166
......@@ -658,25 +658,27 @@ END;';
$tabColumnsTableName = "user_tab_columns";
$colCommentsTableName = "user_col_comments";
$ownerCondition = '';
$tabColumnsOwnerCondition = '';
$colCommentsOwnerCondition = '';
if (null !== $database && '/' !== $database) {
$database = $this->normalizeIdentifier($database);
$database = $this->quoteStringLiteral($database->getName());
$tabColumnsTableName = "all_tab_columns";
$colCommentsTableName = "all_col_comments";
$ownerCondition = "AND c.owner = " . $database;
$tabColumnsOwnerCondition = "AND c.owner = " . $database;
$colCommentsOwnerCondition = "AND d.OWNER = c.OWNER";
}
return "SELECT c.*,
(
SELECT d.comments
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
) AS comments
FROM $tabColumnsTableName c
WHERE c.table_name = " . $table . " $ownerCondition
WHERE c.table_name = " . $table . " $tabColumnsOwnerCondition
ORDER BY c.column_name";
}
......
......@@ -3,6 +3,8 @@
namespace Doctrine\Tests\DBAL\Functional\Schema;
use Doctrine\DBAL\Schema;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\TestUtil;
class OracleSchemaManagerTest extends SchemaManagerFunctionalTestCase
......@@ -216,4 +218,17 @@ class OracleSchemaManagerTest extends SchemaManagerFunctionalTestCase
$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);
}
}
......@@ -725,7 +725,7 @@ EOD;
(
SELECT d.comments
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
) AS comments
FROM user_tab_columns c
......@@ -738,7 +738,7 @@ EOD;
(
SELECT d.comments
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
) AS comments
FROM user_tab_columns c
......@@ -751,7 +751,7 @@ EOD;
(
SELECT d.comments
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
) AS comments
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