Issues with inconsistent table sorting with records having the same value for the sorted column

When sorting a Filament Table it appears to somehow randomise the results order within the records that have the same value that is being sorted. Say I sort on column X and records 1 to 3 have the same db value for column X, the order of records 1, 2 and 3 themselves when sorting seems randomised between 1, 3, / 3, 2, 1 / 1, 3, 2 etc. everytime when the table is "refreshed", for instance when toggling a ToggleColumn or paginating. I also don't see an "in" to add a orderBy('id') as fallback (last orderBy after every query) as this would fix it. Anyone else experienced and solved this somehow?
1 Reply
Mike Peters
Mike PetersOP3w ago
"Hack" right now in the livewire component with the table:
use InteractsWithTable {
applySortingToTableQuery as baseApplySortingToTableQuery;
}

...

protected function applySortingToTableQuery(Builder $query): Builder
{
return $this->baseApplySortingToTableQuery($query)->orderBy('id');
}
use InteractsWithTable {
applySortingToTableQuery as baseApplySortingToTableQuery;
}

...

protected function applySortingToTableQuery(Builder $query): Builder
{
return $this->baseApplySortingToTableQuery($query)->orderBy('id');
}

Did you find this page helpful?