[DC-335] Oracle identifier too long in normal SELECT when using longer table name or column Created: 07/Dec/09 Updated: 13/Oct/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Query |
| Affects Version/s: | 1.2.1 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Miloslav "adrive" Kmet | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 1 |
| 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: {{ An example of large select with alias: |
| Comments |
| Comment by Michel D'HOOGE [ 13/Oct/10 ] |
|
A workaround is available in |
| Comment by Michel D'HOOGE [ 13/Oct/10 ] |
|
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);
}
}
|