Skip to content

Commit 12f2400

Browse files
author
Manus AI
committed
Fix resolveAliasAndColumn to use longest matching relationship path
- Removed early break in path resolution loop - Now correctly resolves asset.financials.monthly_hire_revenue to the financials table alias - Previously was breaking after finding 'asset' and returning the asset table alias - Now continues through all segments and uses the longest matching path - Fixes 'Unknown column' error when computed columns reference nested relationships in aggregates
1 parent b467ef9 commit 12f2400

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

src/Support/Reporting/ReportQueryConverter.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -411,18 +411,15 @@ protected function resolveAliasAndColumn(string $rootTable, string $columnPath):
411411
$currentTable = $rootTable;
412412
$pathSegments = [];
413413

414+
// Loop through all segments and keep updating currentTable with the last successfully resolved alias
414415
foreach ($parts as $segment) {
415416
$pathSegments[] = $segment;
416417
$currentPath = implode('.', $pathSegments);
417418

418419
if (isset($this->joinAliases[$currentPath])) {
419420
$currentTable = $this->joinAliases[$currentPath];
420-
} else {
421-
// Try to find the relationship from the current table
422-
// This handles nested relationships like "asset" -> "financials"
423-
// where we need to use the asset table alias as the base
424-
break;
425421
}
422+
// Don't break - continue to check if there's a longer path that matches
426423
}
427424

428425
// If we resolved at least part of the path, use that table alias

0 commit comments

Comments
 (0)