Skip to content

Commit

Permalink
bug #18 Prohibit association alias from starting with a number (pamil)
Browse files Browse the repository at this point in the history
This PR was merged into the 1.6-dev branch.

Discussion
----------

Hotfix for bug introduced in #17.

Commits
-------

1d033a4 Prohibit association alias from starting with a number
  • Loading branch information
pamil authored Oct 17, 2019
2 parents b8c40b1 + 1d033a4 commit ac57798
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Bundle/Doctrine/ORM/ExpressionBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,14 @@ private function resolveFieldByAddingJoins(string $field): string
}
}

$associationAlias = md5($rootAndAssociationField);
// Association alias can't start with a number
// Mapping numbers to letters will not increase the collision probability and not lower the entropy
$associationAlias = str_replace(
['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
['g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p'],
md5($rootAndAssociationField)
);

$this->queryBuilder->innerJoin($rootAndAssociationField, $associationAlias);
$field = sprintf('%s.%s', $associationAlias, $remainder);
}
Expand Down

0 comments on commit ac57798

Please sign in to comment.