Description
Summary :
I am using Oracle 19
I am facing an issue where my column name is 35 bytes long, and Doctrine cut it to 30 (because of Oracle limitation in version prior to 12.2).
The main reason of this behavior is that Oracle has only one Platform (OraclePlatform) correponding to version <=12.1
Effect : The first char of the resulting identifier is "_" after DefaultQuoteStrategy
call getColumnAlias
.
But a non quoted identifier MUST begin with a letter, and Doctrine was telling me : ORA-00911 : invalid character
.
An example :
getColumnAlias("test_foobar_foobar_foobar_foobar", 5, AbstractPlatform $platform, ?ClassMetadata $class = null)
With a maxIdentifierLength to 30 (OraclePlatform)
string(30) "_foobar_foobar_foobar_foobar_5"
Several way to fix it from my understanding:
-
Create a Oracle122Plateform alternative to manage
getMaxIdentifierLength = 128
(not sure it's really needed) -
Update existing code to force the first char to be a letter
- Update the
OraclePlateform::addSuffix
like this :
dbal/src/Platforms/OraclePlatform.php
Line 648 in 8248359
// an identifier MUST begin with a letter (replace the first char by "I" otherwise) $identifier = preg_replace("/^[^a-zA-Z]/", "I", $identifier);
- Update the
DefaultQuoteStrategy::getColumnAlias
like this :
// an identifier MUST begin with a letter (replace the first char by "I" otherwise) $columnName = preg_replace("/^[^a-zA-Z]/", "I", $columnName );
- Update the
-
Force OraclePlatform to quote identifiers when first char isn't a letter. In
DefaultQuoteStrategy::getColumnAlias
like this :// an identifier MUST begin with a letter (force quoting otherwise) return $this->getSQLResultCasing($platform, (ctype_alpha($columnName[0]) ? $columnName : $platform->quoteIdentifier($columnName ) ));
Thank you to help me to find the best solution to solve my problem. I can make a PR if needed.