Skip to content

Commit

Permalink
Prohibit association alias from starting with a number
Browse files Browse the repository at this point in the history
  • Loading branch information
pamil committed Oct 17, 2019
1 parent b8c40b1 commit 1d033a4
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 1d033a4

Please sign in to comment.