ZF-2927: Zend_Db_Adapter_Oracle - Support describe on view

Description

It should be possible to use Zend_Db_Table on views. But the describeTable function joins with the ALL_TABLES which extracts all views. This applies to Zend_Db_Adapter_Pdo_Oci as well.

Comments

Please categorize/fix as needed.

do I understand this correctly .. do you want me to send you a fix ? I have extended the Zend_Db_Adapter_Oracle and fiex the describe function :D

.. at least where is what we have done to make it work :D

Index: Zend/Db/Adapter/Oracle.php
===================================================================
--- Zend/Db/Adapter/Oracle.php  (revision 9107)
+++ Zend/Db/Adapter/Oracle.php  (working copy)
@@ -287,18 +287,31 @@
      */
     public function describeTable($tableName, $schemaName = null)
     {
-        $sql = "SELECT TC.TABLE_NAME, TB.OWNER, TC.COLUMN_NAME, TC.DATA_TYPE,
-                TC.DATA_DEFAULT, TC.NULLABLE, TC.COLUMN_ID, TC.DATA_LENGTH,
-                TC.DATA_SCALE, TC.DATA_PRECISION, C.CONSTRAINT_TYPE, CC.POSITION
-            FROM ALL_TAB_COLUMNS TC
-            LEFT JOIN (ALL_CONS_COLUMNS CC JOIN ALL_CONSTRAINTS C
-                ON (CC.CONSTRAINT_NAME = C.CONSTRAINT_NAME AND CC.TABLE_NAME = C.TABLE_NAME AND C.CONSTRAINT_TYPE = 'P'))
-              ON TC.TABLE_NAME = CC.TABLE_NAME AND TC.COLUMN_NAME = CC.COLUMN_NAME
-            JOIN ALL_TABLES TB ON (TB.TABLE_NAME = TC.TABLE_NAME AND TB.OWNER = TC.OWNER)
+        $sql = "
+            SELECT
+                TC.TABLE_NAME,
+                TC.OWNER,
+                TC.COLUMN_NAME,
+                TC.DATA_TYPE,
+                TC.DATA_DEFAULT,
+                TC.NULLABLE,
+                TC.COLUMN_ID,
+                TC.DATA_LENGTH,
+                TC.DATA_SCALE,
+                TC.DATA_PRECISION,
+                C.CONSTRAINT_TYPE,
+                CC.POSITION
+            FROM
+                ALL_TAB_COLUMNS TC
+                    LEFT JOIN (
+                    ALL_CONS_COLUMNS CC JOIN ALL_CONSTRAINTS C ON (
+                        CC.CONSTRAINT_NAME = C.CONSTRAINT_NAME AND CC.TABLE_NAME = C.TABLE_NAME AND C.CONSTRAINT_TYPE = 'P'
+                    )
+                ) ON TC.TABLE_NAME = CC.TABLE_NAME AND TC.COLUMN_NAME = CC.COLUMN_NAME
             WHERE "
             . $this->quoteInto('UPPER(TC.TABLE_NAME) = UPPER(?)', $tableName);
         if ($schemaName) {
-            $sql .= $this->quoteInto(' AND UPPER(TB.OWNER) = UPPER(?)', $schemaName);
+            $sql .= $this->quoteInto(' AND UPPER(TC.OWNER) = UPPER(?)', $schemaName);
         }
         $sql .= ' ORDER BY TC.COLUMN_ID';

any progress ? :D

Reassigning to Ralph since he's the new maintainer of Zend_Db

Fixed in SVN13083

Merged to 1.7-branch