CakeDC / cakephp-oracle-driver

CakePHP 3 Driver for Oracle Database
Other
40 stars 24 forks source link

ORA-00972: identifier is too long #9

Closed snelg closed 2 years ago

snelg commented 8 years ago

Oracle has a 30-character limit for identifiers, including aliases. Cake creates field aliases using the pattern "Tablealias__fieldname", which not infrequently results in more than 30 characters, especially in the legacy systems I deal with. I'd be more than happy to leave my own Cake 3 Oracle driver behind as a historical relic, but I can't switch to your much more robust driver without this issue being addressed somehow. I'm genuinely embarrassed to exhibit this code, but here's the quick-and-dirty workaround I did in my driver: https://github.com/snelg/cakephp-3-oracle/commit/e7feaa0b28de06faa148f1649f5486c79a5b2de4

So that's a general idea for one solution or, more likely, an example of what to avoid at all costs :)

snelg commented 8 years ago

I was going to write up a clean "steps to reproduce", but it looks like two of the existing unit tests already trigger this error:

phpunit --filter testAssociationSubQueryNoOffset

and

phpunit --filter testPolymorphicBelongsToManySave
lucasmezencio commented 8 years ago

You saved my life with DB2! Thanks! :smiley:

xavier83ar commented 7 years ago

Any news on this?

skie commented 7 years ago

There is partial solution implemented in identifier_issue branch

jmbIFR commented 3 years ago

cakePHP 4.0.2 added an helper in debug mode and now throw exception

ORM queries generate field aliases using the table name/alias and column name. 
The table alias `{$table}` and column `{$name}` create an alias longer than ({$nameLength}). 
You must change the table schema in the database and shorten either the table or column 
identifier so they fit within the database alias limits.

The driver should add the max length

protected const MAX_ALIAS_LENGTH = 30;
skie commented 2 years ago

merged