What happened?
When sorting by a column that defines a sort query, the HasRecordsList makes an additional query for the ids, but it does not apply the sort function from the column but instead tries to sort with the column name.
How to reproduce the bug
I ran into this while trying to set up sorting by a field on another record.
TextColumn::make('auction_name')
->label('Auction')
->sortable(query: function(Builder $query, string $direction) {
$query->withAggregate('Auction', 'name')
->orderBy('auction_name');
}),
When sorting by auction, I get this error:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'auction_name' in 'order clause'
select
id
from
consignments
where
balance_due > 0
and consignments.deleted_at is null
order by
auction_name asc
If I remove the HasRecordsList trait, the error goes away.
Package Version
2.2.2
PHP Version
8.2.27
Laravel Version
10.48.29
Which operating systems does with happen with?
macOS
Notes
No response
What happened?
When sorting by a column that defines a sort query, the HasRecordsList makes an additional query for the ids, but it does not apply the sort function from the column but instead tries to sort with the column name.
How to reproduce the bug
I ran into this while trying to set up sorting by a field on another record.
When sorting by auction, I get this error:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'auction_name' in 'order clause'
select
idfrom
consignmentswhere
balance_due> 0and
consignments.deleted_atis nullorder by
auction_nameascIf I remove the HasRecordsList trait, the error goes away.
Package Version
2.2.2
PHP Version
8.2.27
Laravel Version
10.48.29
Which operating systems does with happen with?
macOS
Notes
No response