Closed samloft closed 5 years ago
When having 2 database, and one of those database has a table prefix, the table prefix is getting appended to the subquery on whereHas().
Have 2 connection, e.g:
'1' => [ 'driver' => 'sqlsrv', 'host' => env('DB_HOST', 'localhost'), 'port' => env('DB_PORT', '1433'), 'database' => env('DB_DATABASE', 'forge'), 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''), 'charset' => 'utf8', 'prefix' =>'anything_, ], '2' => [ 'driver' => 'sqlsrv', 'host' => env('DB_HOST', 'localhost'), 'port' => env('DB_PORT', '1433'), 'database' => env('DB_SAGE', 'demo'), 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''), 'charset' => 'utf8', 'prefix' => '', ],
Add relationships and two models, 1 for each database and an example function
return (new Orders)->whereDate('processed_at', '<=', Carbon::now()->subHours(1))->whereHas('orderBook', function($query) { $query->where('alpha', 'ZZZ'); })->get();
Description:
When having 2 database, and one of those database has a table prefix, the table prefix is getting appended to the subquery on whereHas().
Steps To Reproduce:
Have 2 connection, e.g:
Add relationships and two models, 1 for each database and an example function