livewire-datatables icon indicating copy to clipboard operation
livewire-datatables copied to clipboard

Get DB connection from builder

Open saulens22 opened this issue 3 years ago • 5 comments

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.

saulens22 avatar Apr 10 '22 01:04 saulens22

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.

thyseus avatar Apr 12 '22 18:04 thyseus

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

saulens22 avatar Apr 12 '22 22:04 saulens22

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.

saulens22 avatar Apr 12 '22 22:04 saulens22

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

thyseus avatar May 11 '22 10:05 thyseus

@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.

shaneburrell avatar May 12 '22 16:05 shaneburrell