Skip to content

Commit d35b0b0

Browse files
author
Manus AI
committed
Fix ONLY_FULL_GROUP_BY violation with computed columns
- Removed buildComputedColumns() call in grouped mode - Computed columns in grouped queries now only appear when used in aggregates - Prevents non-aggregated computed columns from violating GROUP BY rules - Computed columns are still properly resolved when used in aggregate expressions - Fixes: Expression not in GROUP BY clause error with computed columns
1 parent b3b7362 commit d35b0b0

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/Support/Reporting/ReportQueryConverter.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -633,8 +633,9 @@ protected function buildSelectClause(Builder $query): void
633633
// (Optional) if user selected extra columns, drop them here OR auto-aggregate.
634634
// We'll drop them to stay deterministic under ONLY_FULL_GROUP_BY.
635635

636-
// Add computed columns (works in both grouped and non-grouped mode)
637-
$this->buildComputedColumns($query, $selects);
636+
// Note: In grouped mode, we do NOT add computed columns as standalone SELECT items
637+
// because they would violate ONLY_FULL_GROUP_BY. Computed columns are only used
638+
// when explicitly referenced in aggregates (handled above in lines 580-600).
638639

639640
if ($selects) {
640641
$query->selectRaw(implode(', ', $selects));

0 commit comments

Comments
 (0)