Commit ecc99eee authored by Marco Pivetta's avatar Marco Pivetta

Merge pull request #628 from rehfeldchris/db2v10columnbugfix

bug fix for db2 v10 new column def of syscat.columns.default
parents 51074ffd f6e24cf6
...@@ -234,7 +234,7 @@ class DB2Platform extends AbstractPlatform ...@@ -234,7 +234,7 @@ class DB2Platform extends AbstractPlatform
} }
/** /**
* This code fragment is originally from the Zend_Db_Adapter_Db2 class. * This code fragment is originally from the Zend_Db_Adapter_Db2 class, but has been edited.
* *
* @license New BSD License * @license New BSD License
* *
...@@ -245,9 +245,26 @@ class DB2Platform extends AbstractPlatform ...@@ -245,9 +245,26 @@ class DB2Platform extends AbstractPlatform
*/ */
public function getListTableColumnsSQL($table, $database = null) public function getListTableColumnsSQL($table, $database = null)
{ {
return "SELECT DISTINCT c.tabschema, c.tabname, c.colname, c.colno, // We do the funky subquery and join syscat.columns.default this crazy way because
c.typename, c.default, c.nulls, c.length, c.scale, // as of db2 v10, the column is CLOB(64k) and the distinct operator won't allow a CLOB,
c.identity, tc.type AS tabconsttype, k.colseq, // it wants shorter stuff like a varchar.
return "
SELECT
cols.default,
subq.*
FROM (
SELECT DISTINCT
c.tabschema,
c.tabname,
c.colname,
c.colno,
c.typename,
c.nulls,
c.length,
c.scale,
c.identity,
tc.type AS tabconsttype,
k.colseq,
CASE CASE
WHEN c.generated = 'D' THEN 1 WHEN c.generated = 'D' THEN 1
ELSE 0 ELSE 0
...@@ -260,7 +277,15 @@ class DB2Platform extends AbstractPlatform ...@@ -260,7 +277,15 @@ class DB2Platform extends AbstractPlatform
ON (c.tabschema = k.tabschema ON (c.tabschema = k.tabschema
AND c.tabname = k.tabname AND c.tabname = k.tabname
AND c.colname = k.colname) AND c.colname = k.colname)
WHERE UPPER(c.tabname) = UPPER('" . $table . "') ORDER BY c.colno"; WHERE UPPER(c.tabname) = UPPER('" . $table . "')
ORDER BY c.colno
) subq
JOIN syscat.columns cols
ON subq.tabschema = cols.tabschema
AND subq.tabname = cols.tabname
AND subq.colno = cols.colno
ORDER BY subq.colno
";
} }
/** /**
......
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