Issue with ExportAction on table with defaultSort() on a relationship attribute

Hello,

while trying to export this table data we get this error:

Next Illuminate\Database\QueryException: SQLSTATE[42P10]: Invalid column reference: 7 ERROR: SELECT DISTINCT ON expressions must match initial ORDER BY expressions LINE 1: select distinct on ("reseller_prices"."id") * from "reseller_prices" where "reseller_prices"."rate_reseller_id" = 2 and "reseller_prices"."rate_reseller_id" is not null order by (select "destination" from "destinations" where "reseller_prices"."destination_id" = "destinations"."id") asc limit 100 offset 0

Are we missing something or is this a BUG? Thanks
This is our code (Models involved and Resource Table).

class ResellerPrice extends Model { use HasFactory; /** * The attributes that aren't mass assignable. * * @var array */ protected $guarded = []; public function destination(): BelongsTo { return $this->belongsTo(Destination::class); } }

public function table(Table $table): Table { return $table ->recordTitleAttribute('id') ->columns([ TextColumn::make('destination.destination') ->sortable(), TextColumn::make('destination.description') ->sortable(), TextColumn::make('price'), TextColumn::make('connection_charge'), TextColumn::make('billing_increment') ]) ->defaultSort('destination.destination') ->filters([ // ]) ->headerActions([ ExportAction::make() ->exporter(ResellerPriceExporter::class) ->formats([ ExportFormat::Xlsx, ExportFormat::Csv, ]), ]) ->actions([ // ]) ->bulkActions([ // ]); } }
Was this page helpful?