Skip to content

Commit

Permalink
chore(databases): 禁用 ONLY_FULL_GROUP_BY 模式
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaiyuxin103 committed Dec 10, 2024
1 parent 045667a commit 6185937
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use App\Models\User;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Facades\Log;
Expand Down Expand Up @@ -75,5 +76,10 @@ public function boot(): void
]);
Auth::setUser($event->impersonator);
});

if (config('database.default') === 'mysql') {
// Disable ONLY_FULL_GROUP_BY if it is enabled
DB::statement("SET sql_mode=(SELECT REPLACE(@@sql_mode, 'ONLY_FULL_GROUP_BY', ''))");
}
}
}

0 comments on commit 6185937

Please sign in to comment.