DDC-1384: ORA-00972: identifier is too long #1734

Closed
opened 2026-01-22 13:23:37 +01:00 by admin · 11 comments
Owner

Originally created by @doctrinebot on GitHub (Sep 19, 2011).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user matheus.souza:

Hi,

When the query is executed the follow problem occur:
ORA-00972:identifier is too long
The problem occur because a column name has 30 characters and the
Doctrine creates an alias with <columnname>+<position_inselect>
becoming 31 characters, in Oracle the max allowed characters in the name
is 30.
Is there any configuration that disable this mechanism?
How can I solve this issue?
Thanks!
Regards,

Matheus Souza.

Originally created by @doctrinebot on GitHub (Sep 19, 2011). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user matheus.souza: Hi, When the query is executed the follow problem occur: ORA-00972:identifier is too long The problem occur because a column name has 30 characters and the Doctrine creates an alias with <column*name>+<position_in*select> becoming 31 characters, in Oracle the max allowed characters in the name is 30. Is there any configuration that disable this mechanism? How can I solve this issue? Thanks! Regards, Matheus Souza.
admin added the Bug label 2026-01-22 13:23:37 +01:00
admin closed this issue 2026-01-22 13:23:38 +01:00
Author
Owner

@doctrinebot commented on GitHub (Sep 25, 2011):

Comment created by @beberlei:

This is tricky. No way for you to reduce the column length to < 30 chars? The problem with a fix for this would be that we would need to execute a bunch of functions for every database vendor and every column alias used in every SQL statement: quite some overhead :-(

@doctrinebot commented on GitHub (Sep 25, 2011): Comment created by @beberlei: This is tricky. No way for you to reduce the column length to < 30 chars? The problem with a fix for this would be that we would need to execute a bunch of functions for every database vendor and every column alias used in every SQL statement: quite some overhead :-(
Author
Owner

@doctrinebot commented on GitHub (Sep 26, 2011):

Comment created by matheus.souza:

I get it. :-(
I don't know the implementation, but is there a possibilty to create a property that disable the "suffix field position" in alias, staying just <column_name>?

Tks!

@doctrinebot commented on GitHub (Sep 26, 2011): Comment created by matheus.souza: I get it. :-( I don't know the implementation, but is there a possibilty to create a property that disable the "suffix field position" in alias, staying just <column_name>? Tks!
Author
Owner

@doctrinebot commented on GitHub (Oct 15, 2011):

Comment created by @beberlei:

The following workaround will get you around this problem until i find a better solution.

  1. Create a MyOraclePlatform extends \Doctrine\DBAL\Platforms\OraclePlatform
  2. Override the "getSQLResultCasing($string)" to do:
$val = parent::getSQLResultCasing($string);
return substr($val, -30);

This substrings every result alias to 30 chars.

@doctrinebot commented on GitHub (Oct 15, 2011): Comment created by @beberlei: The following workaround will get you around this problem until i find a better solution. 1. Create a MyOraclePlatform extends \Doctrine\DBAL\Platforms\OraclePlatform 2. Override the "getSQLResultCasing($string)" to do: ``` $val = parent::getSQLResultCasing($string); return substr($val, -30); ``` This substrings every result alias to 30 chars.
Author
Owner

@doctrinebot commented on GitHub (Oct 17, 2011):

Comment created by matheus.souza:

But how does the Doctrine will know about my implementation?
I will have to change the Driver too?

Thanks!

@doctrinebot commented on GitHub (Oct 17, 2011): Comment created by matheus.souza: But how does the Doctrine will know about my implementation? I will have to change the Driver too? Thanks!
Author
Owner

@doctrinebot commented on GitHub (Oct 17, 2011):

Comment created by @beberlei:

no, you can pass the "platform" into the DriverManager::create method as "platform" parameter for the $params AFAIK, relevant code is Doctrine\DBAL\Connection::**construct if you want to check it out.

@doctrinebot commented on GitHub (Oct 17, 2011): Comment created by @beberlei: no, you can pass the "platform" into the DriverManager::create method as "platform" parameter for the $params AFAIK, relevant code is Doctrine\DBAL\Connection::**construct if you want to check it out.
Author
Owner

@doctrinebot commented on GitHub (Oct 17, 2011):

Comment created by matheus.souza:

In some cases it works, but it doesn't work when the SqlWalker is invoked, I think that the problem is in walkSelectClause($selectClause) method in the else clause for this verification:

if ($class->isInheritanceTypeSingleTable() || $class->isInheritanceTypeJoined()) {
if ($class->isInheritanceTypeSingleTable() || $class->isInheritanceTypeJoined()) {
...
} else {
                // Add foreign key columns to SQL, if necessary
                if ($addMetaColumns) {
                    $sqlTableAlias = $this->getSqlTableAlias($class->table['name'], $dqlAlias);
                    foreach ($class->associationMappings as $assoc) {
                        if ($assoc['isOwningSide'] && $assoc['type'] & ClassMetadata::TO_ONE) {
                            foreach ($assoc['targetToSourceKeyColumns'] as $srcColumn) {
                                $columnAlias = $this->getSqlColumnAlias($srcColumn);
                                $sql .= ', ' . $sqlTableAlias . '.' . $srcColumn . ' AS ' . $columnAlias;
                                $columnAlias = $this->_platform->getSQLResultCasing($columnAlias);
                                $this->*rsm->addMetaResult($dqlAlias, $this->*platform->getSQLResultCasing($columnAlias), $srcColumn);
                            }
                        }
                    }
                }
            }
        }

the problem is in the follow lines, because the getSQLResultCasing has no effect in $sql variable that is returned:

$columnAlias = $this->getSqlColumnAlias($srcColumn);
$sql .= ', ' . $sqlTableAlias . '.' . $srcColumn . ' AS ' . $columnAlias;
$columnAlias = $this->_platform->getSQLResultCasing($columnAlias);

The correct would be this way, wouldn't be?

$columnAlias = $this->getSqlColumnAlias($srcColumn);
$columnAlias = $this->_platform->getSQLResultCasing($columnAlias);
$sql .= ', ' . $sqlTableAlias . '.' . $srcColumn . ' AS ' . $columnAlias;
  • In the version of Doctrine that I'm using, there is no DriverManager::create method, I'm using
    DriverManager::getConnection(array $params,Configuration $config = null,EventManager $eventManager = null) instead.

Tks!!

@doctrinebot commented on GitHub (Oct 17, 2011): Comment created by matheus.souza: In some cases it works, but it doesn't work when the SqlWalker is invoked, I think that the problem is in walkSelectClause($selectClause) method in the else clause for this verification: ``` if ($class->isInheritanceTypeSingleTable() || $class->isInheritanceTypeJoined()) { ``` ``` if ($class->isInheritanceTypeSingleTable() || $class->isInheritanceTypeJoined()) { ... } else { // Add foreign key columns to SQL, if necessary if ($addMetaColumns) { $sqlTableAlias = $this->getSqlTableAlias($class->table['name'], $dqlAlias); foreach ($class->associationMappings as $assoc) { if ($assoc['isOwningSide'] && $assoc['type'] & ClassMetadata::TO_ONE) { foreach ($assoc['targetToSourceKeyColumns'] as $srcColumn) { $columnAlias = $this->getSqlColumnAlias($srcColumn); $sql .= ', ' . $sqlTableAlias . '.' . $srcColumn . ' AS ' . $columnAlias; $columnAlias = $this->_platform->getSQLResultCasing($columnAlias); $this->*rsm->addMetaResult($dqlAlias, $this->*platform->getSQLResultCasing($columnAlias), $srcColumn); } } } } } } ``` the problem is in the follow lines, because the getSQLResultCasing has no effect in $sql variable that is returned: ``` $columnAlias = $this->getSqlColumnAlias($srcColumn); $sql .= ', ' . $sqlTableAlias . '.' . $srcColumn . ' AS ' . $columnAlias; $columnAlias = $this->_platform->getSQLResultCasing($columnAlias); ``` The correct would be this way, wouldn't be? ``` $columnAlias = $this->getSqlColumnAlias($srcColumn); $columnAlias = $this->_platform->getSQLResultCasing($columnAlias); $sql .= ', ' . $sqlTableAlias . '.' . $srcColumn . ' AS ' . $columnAlias; ``` - In the version of Doctrine that I'm using, there is no DriverManager::create method, I'm using DriverManager::getConnection(array $params,Configuration $config = null,EventManager $eventManager = null) instead. Tks!!
Author
Owner

@doctrinebot commented on GitHub (Oct 17, 2011):

Comment created by @beberlei:

Narf, sorry that this doesn't work.

This is rather unreliable if this fails here, can we trust it in other places? I think i have to work on this by hard, its just very problematic to test this, it may be easy to miss a location.

@doctrinebot commented on GitHub (Oct 17, 2011): Comment created by @beberlei: Narf, sorry that this doesn't work. This is rather unreliable if this fails here, can we trust it in other places? I think i have to work on this by hard, its just very problematic to test this, it may be easy to miss a location.
Author
Owner

@doctrinebot commented on GitHub (Oct 17, 2011):

Comment created by @beberlei:

we found a simple way to fix this, expect a patch for this soon!

@doctrinebot commented on GitHub (Oct 17, 2011): Comment created by @beberlei: we found a simple way to fix this, expect a patch for this soon!
Author
Owner

@doctrinebot commented on GitHub (Oct 26, 2011):

Comment created by @asm89:

The issue should be fixed with the code over here:
https://github.com/doctrine/doctrine2/pull/167

I haven't been able to test it on a real Oracle DB yet. Maybe you guys can give it a go?

@doctrinebot commented on GitHub (Oct 26, 2011): Comment created by @asm89: The issue should be fixed with the code over here: https://github.com/doctrine/doctrine2/pull/167 I haven't been able to test it on a real Oracle DB yet. Maybe you guys can give it a go?
Author
Owner

@doctrinebot commented on GitHub (Oct 30, 2011):

Comment created by @beberlei:

Fixed, however will not be merged into 2.1.x because the patch is really large

@doctrinebot commented on GitHub (Oct 30, 2011): Comment created by @beberlei: Fixed, however will not be merged into 2.1.x because the patch is really large
Author
Owner

@doctrinebot commented on GitHub (Oct 30, 2011):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Oct 30, 2011): Issue was closed with resolution "Fixed"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#1734