MedicOneSystems / livewire-datatables

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

Get DB connection from builder #441

Closed saulens22 closed 1 year ago

saulens22 commented 2 years ago

When using non-default connection model, sort expression is still derived from default connection.

In my project, I use MySQL as default connection and SQLSRV as model connection. Sort queries always fail with Incorrect syntax near '`'.

This PR is supposed to fix this problem. It might be possible that DB::raw() calls might be affected by similar problems, I will look into it.

thyseus commented 2 years ago

Thanks a lot for your contribution. I will review and test it with my projects that have datatables implemented in my office soon (next days) and will give feedback / merge it.

saulens22 commented 2 years ago

I am still finding bugs, hope I will squash them by that time

saulens22 commented 2 years ago

I should note that this is a quick and dirty workaround. It should be possible to get DB connection (or at least name) from the model itself, but as far as I know there are no static methods for that.

thyseus commented 2 years ago

Is https://github.com/MedicOneSystems/livewire-datatables/pull/450 possibly fixing this issue ?

shaneburrell commented 2 years ago

@saulens22 I have fixed a few of these in my fork (not maintained just so I could get something deployable). You are welcome to take a look at those mods, may help with direction you were headed in this PR. Most of the locations it should lookup the db conn it doesn't but there was a an easy way to get it from the model which is avail most places in the code.