MedicOneSystems / livewire-datatables

Advanced datatables using Laravel, Livewire, Tailwind CSS and Alpine JS
https://livewire-datatables.com/
MIT License
1.2k stars 259 forks source link

Sorting is broken after upgrade from v0.9.3 to v0.9.4 #453

Open nikitabuida opened 2 years ago

nikitabuida commented 2 years ago

If I set defaultSort on a column or just leave it unspecified, sorting on any column doesn't work.

If I sort by 'id' cloumn and look at queries in debugbar I see the following:

v0.9.4: select .... order by 'id'                                    <--- this doesn't work and clicking on any column doesn't do anything
v0.9.3: select .... order by `id`                      <--- this works fine and clicking on any column also works as expected

So maybe there was some bug with sql statements introduced in latest release.

shaneburrell commented 2 years ago

What DB in the backend?

nikitabuida commented 2 years ago

What DB in the backend?

MySQL server

shaneburrell commented 2 years ago

There is a pull request started by someone else where they were trying to do proper database detection. Right now it doesn't do a great job with different databases or multiple connections. The backticks have been flipped several times and what really needs to happen is detect database type. Another example is hasMany on tables fails because sqlserver doesn't have a group concat function.

shaneburrell commented 2 years ago

@nikitabuida I have some corrections for this in my fork. The dbtype needed to be passed into the sort function. Feel free to try my forked package for testing or transpose those changes into this main branch as a PR.

mtx-z commented 2 years ago

Can confirm the same issue: ordering is broken on MySQL MariaDB + 0.9.4 (click as no data ordering effect), but is functional in 0.9.3. Easy solution was to change my composer.json to "mediconesystems/livewire-datatables": "0.9.3" and composer update.

Christophvh commented 2 years ago

can confirm. Same issue for date sorting. Works on 0.9.3 broken on 0.9.4

Related: https://github.com/MedicOneSystems/livewire-datatables/issues/391