Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: 1.2.1
-
Fix Version/s: None
-
Component/s: Query
-
Labels:None
-
Environment:Oracle
Description
Unfortunatelly oracle has max identifier length for 30 characters. When using longer model names eg. misCompanyContributor with column names the generated aliases for selected columns mix tableized modelname with colum name joined by two __, and sometimes the generated alias should exceed the allowed 30 characters long identifiers, and oracle complains with:
{{
ORA-00972: identifier is too long
}}
An example of large select with alias:
{{
SELECT
...
mis_contributor.contributor_id AS mis_contributor__contributor_id
..
FROM mis_contributor ...
}}
I have applied the following patch to use aliases of identifiers (what is after the "as" when defining field name).
So far, it seems to work... But I am quite sure I didn't take all possible cases into consideration.
--- lib/vendor/doctrine/Doctrine/Hydrator/Graph.php.orig 2010-10-07 19:09:10.000000000 +0200 +++ lib/vendor/doctrine/Doctrine/Hydrator/Graph.php 2010-10-14 00:08:05.000000000 +0200 @@ -298,10 +298,10 @@ } $e = explode('__', $key); - $last = strtolower(array_pop($e)); + $fieldName = strtolower(array_pop($e)); $cache[$key]['dqlAlias'] = $this->_tableAliases[strtolower(implode('__', $e))]; $table = $this->_queryComponents[$cache[$key]['dqlAlias']]['table']; - $fieldName = $table->getFieldName($last); + $last = $table->getColumnName($fieldName); $cache[$key]['fieldName'] = $fieldName; if ($table->isIdentifier($fieldName)) { $cache[$key]['isIdentifier'] = true; --- lib/vendor/doctrine/Doctrine/Query.php.orig 2010-10-07 19:09:10.000000000 +0200 +++ lib/vendor/doctrine/Doctrine/Query.php 2010-10-14 00:03:28.000000000 +0200 @@ -494,12 +494,12 @@ $parentAlias = $this->getSqlTableAlias($componentAlias . '.' . $parent->getComponentName()); $sql[] = $this->_conn->quoteIdentifier($parentAlias) . '.' . $this->_conn->quoteIdentifier($columnName) . ' AS ' - . $this->_conn->quoteIdentifier($tableAlias . '__' . $columnName); + . $this->_conn->quoteIdentifier($tableAlias . '__' . $fieldName); } else { - $columnName = $table->getColumnName($fieldName); + $columnName = $table->getColumnName($fieldName); // Really needed? $sql[] = $this->_conn->quoteIdentifier($tableAlias) . '.' . $this->_conn->quoteIdentifier($columnName) . ' AS ' - . $this->_conn->quoteIdentifier($tableAlias . '__' . $columnName); + . $this->_conn->quoteIdentifier($tableAlias . '__' . $fieldName); } } @@ -554,7 +554,7 @@ return $this->_conn->quoteIdentifier($tableAlias . '.' . $name) . ' AS ' - . $this->_conn->quoteIdentifier($tableAlias . '__' . $name); + . $this->_conn->quoteIdentifier($tableAlias . '__' . $field); } }