mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-3769: Doctine column name truncation can cause syntax errors in Oracle #4620
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @doctrinebot on GitHub (Jun 12, 2015).
Originally assigned to: @ostrolucky on GitHub.
Jira issue originally created by user jzullo:
Reproduction
Given the following entity:
and a table defined as
and populated with a single record of id = 1
Run the following:
Expected Results
We find the record with ID = 1 and return the corresponding entity
Actual Results
We die with an exception:
This is caused by the first character in the column name becoming _ after truncation.
Oracle has a maximum column length of 30 characters, so Doctrine truncates the column after applying the *N suffix to guarantee unique column aliases. However, this causes a problem with the *N suffix is the same length as the number of characters before the first underscore in said column for Oracle.
@jlz9811 commented on GitHub (Dec 18, 2015):
Looks like doctrinebot transformed all of my _ characters to * characters (e.g. it should be test_doctrine_defect, not testdoctrinedefect)
@jameshollenbeck commented on GitHub (Jul 7, 2016):
Just wondering if this will make any short-term release -- I had to introduce an extension in our codebase for now - but wondering if I can tell the gang my fix can be removed in due-time. Thanks!
@Ocramius commented on GitHub (Jul 7, 2016):
@doctrinebot no fixes introduced for this so far, as far as I know. Also, we'd have to push alias definition down to the DBAL /cc @deeky666
@jameshollenbeck commented on GitHub (Jul 7, 2016):
Just to note my current fix - I extended the default quote strategy, and set my new class in config.yml in symfony/doctrine - it's working fine as far as I can tell.
@deeky666 commented on GitHub (Jul 7, 2016):
This is not strictly related to column aliases but to identifiers in general. How were you even able to define a column with a name > 30 characters in the first place?
@deeky666 commented on GitHub (Jul 7, 2016):
Ah no wait I think I misunderstood. Will have a closer look at it again.
@deeky666 commented on GitHub (Jul 7, 2016):
Looking at this again I think it is a problem with the
DefaultQuoteStrategyhere.@jremerich commented on GitHub (Jul 29, 2016):
Any solution for this? I'm using doctrine in laravel. Tks!
@jremerich commented on GitHub (Jul 29, 2016):
For now, I'm change this for this:
$columnName = preg_replace('/[^A-Za-z0-9]/', '', $columnName);The follow line don't put the '_' in fields numerics, by the way
@ostrolucky commented on GitHub (Aug 7, 2018):
In Doctrine 3.x, everything is quoted by default, which solves this issue