Code working in filament v2.16.52 and broken when I update today

Hello guys, I was using filament v2.16.52 and this code in a widget is working well. protected function getTableQuery(): Builder { return AvAnsweredForm::selectRaw(" MIN(id) as id, DATE_FORMAT(realized_date, '%Y-%m') AS year_and_month, SUM((CASE WHEN answer_type = 'A' THEN 1 ELSE 0 END)) AS auto, SUM((CASE WHEN answer_type = 'B' THEN 1 ELSE 0 END)) AS boss, SUM((CASE WHEN answer_type = 'S' THEN 1 ELSE 0 END)) AS sub") ->groupBy('year_and_month') ->orderBy('year_and_month', 'DESC'); } protected function getTableColumns(): array { return [ Tables\Columns\TextColumn::make('year_and_month') ->label('Ano - Mês'), Tables\Columns\TextColumn::make('auto') ->label('Auto'), Tables\Columns\TextColumn::make('boss') ->label('Chefia'), Tables\Columns\TextColumn::make('sub') ->label('Subcomissão'), ]; } today, I try to update and I am receiveing a SQL error saying the column year_and_month was not found. any suggestions about my error ?
7 Replies
Dan Harrin
Dan Harrin2y ago
Please post the flare exception URL click "share" also 19.52 was 4-5 months ago, please identify the actual version that broke it
LeandroFerreira
Maybe raw...
->orderByRaw("DATE_FORMAT(realized_date, '%Y-%m') DESC")
->orderByRaw("DATE_FORMAT(realized_date, '%Y-%m') DESC")
Dennis Koch
Dennis Koch2y ago
Or a addSelect(DB::raw())
LeandroFerreira
@rodolfostein did it work?
RodolfoStein
RodolfoSteinOP2y ago
excuse-me guys, I am out for a while. let´s go to the tests. the release was working good with version 2.16.52 after update to 2.17.11 error message SQLSTATE[42S22]: Column not found: 1054 Unknown column 'year_and_month' in 'order clause' Changing to orderByRaw (as suggested by Leandro Ferreira) error message SQLSTATE[42S22]: Column not found: 1054 Unknown column 'year_and_month' in 'group statement' Now, I will try to rewrite the query to receive the same statistics without using group by. But, what the new versions change that broke the first query ? If I run the query directly in mysql workbench, it runs perfectly.
LeandroFerreira
->groupByRaw("DATE_FORMAT(realized_date, '%Y-%m')")
->groupByRaw("DATE_FORMAT(realized_date, '%Y-%m')")
?
RodolfoStein
RodolfoSteinOP2y ago
it works ! these "byRaw" options are new to me... I will study the difference to know how to use. Thank you for your help.
Want results from more Discord servers?
Add your server