1
0
mirror of synced 2024-12-05 03:06:05 +03:00

Fix issue in LimitSubqueryOutputWalker with entities having field names different from column names

This commit is contained in:
Bill Schaller 2015-03-31 13:59:24 -04:00 committed by Marco Pivetta
parent 9d7aa9ba39
commit 5c93e61686

View File

@ -410,27 +410,27 @@ class LimitSubqueryOutputWalker extends SqlWalker
$fieldSearchPattern = '/(?<![a-z0-9_])%s\.%s(?![a-z0-9_])/i';
// Generate search patterns for each field's path expression in the order by clause
foreach($this->rsm->fieldMappings as $fieldAlias => $columnName) {
foreach($this->rsm->fieldMappings as $fieldAlias => $fieldName) {
$dqlAliasForFieldAlias = $this->rsm->columnOwnerMap[$fieldAlias];
$class = $dqlAliasToClassMap[$dqlAliasForFieldAlias];
// If the field is from a joined child table, we won't be ordering
// on it.
if (!isset($class->fieldMappings[$columnName])) {
if (!isset($class->fieldMappings[$fieldName])) {
continue;
}
$fieldMapping = $class->fieldMappings[$fieldName];
// Get the proper column name as will appear in the select list
$columnName = $this->quoteStrategy->getColumnName(
$columnName,
$fieldName,
$dqlAliasToClassMap[$dqlAliasForFieldAlias],
$this->em->getConnection()->getDatabasePlatform()
);
// Get the SQL table alias for the entity and field
$sqlTableAliasForFieldAlias = $dqlAliasToSqlTableAliasMap[$dqlAliasForFieldAlias];
$fieldMapping = $class->fieldMappings[$columnName];
if (isset($fieldMapping['declared']) && $fieldMapping['declared'] !== $class->name) {
// Field was declared in a parent class, so we need to get the proper SQL table alias
// for the joined parent table.