BUGFIX: prevent creating new alias for columns after filters changed#12228
Open
danfraticiu wants to merge 1 commit intodoctrine:3.6.xfrom
Open
BUGFIX: prevent creating new alias for columns after filters changed#12228danfraticiu wants to merge 1 commit intodoctrine:3.6.xfrom
danfraticiu wants to merge 1 commit intodoctrine:3.6.xfrom
Conversation
a47e551 to
6d435a6
Compare
|
Is it possible to get this fix into 2.20.x too? Also; this is kind of a critical bug too us, since we are unable to upgrade doctrine before this is fixed. Hope this get fixed as soon as possible 🙏 If anyone have a temporary workaround it would be very much appreciated. |
|
A better solution to this issue might be to change AbstractEntityInheritancePersister::getSelectColumnSQL to check if the column alias already exist, similar to how it's done in BasicEntityPersister::getSelectColumnSQL $columnAlias = null;
if ($this->currentPersisterContext->rsm->hasColumnAliasByField($alias, $field)) {
$columnAlias = $this->currentPersisterContext->rsm->getColumnAliasByField($alias, $field);
}
if ($columnAlias === null) {
$columnAlias = $this->getSQLColumnAlias($fieldMapping->columnName);
}Added a PR with this solution: #12373 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As described in issue 12225
When there is a oneToMany relation where the children use single table inheritance, if the relation is re-fetched after a filter changed,
SingleTablePersister::getSelectColumnsSQLwill generate new aliases for the child entity fields. ThenResultSetMapping::addIndexBypicks the first alias that matches theindexByfield, which doesn't exist in the updated list. This causes ObjectHydrator:502 to throw anErrorException: Warning: Undefined array keyThis PR prevent creating new aliases.
The change is inspired by the code in
BasicEntityPersister::getSelectColumnSQLwhich reuses the aliases that already exist.