From ee8503886d2c32bd34fcf18826b9dd951408893d Mon Sep 17 00:00:00 2001 From: hackerESQ Date: Wed, 11 Sep 2024 23:30:42 -0500 Subject: [PATCH] make setting cte optional --- app/Models/Holding.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/Models/Holding.php b/app/Models/Holding.php index 5848841..d9f9b06 100644 --- a/app/Models/Holding.php +++ b/app/Models/Holding.php @@ -8,6 +8,7 @@ use App\Models\Portfolio; use App\Models\MarketData; use App\Models\Transaction; use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\Log; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Concerns\HasUuids; use Illuminate\Database\Eloquent\Factories\HasFactory; @@ -231,13 +232,18 @@ class Holding extends Model $date_interval = "DATE_ADD(date, INTERVAL 1 DAY)"; + try { + + DB::statement('SET GLOBAL cte_max_recursion_depth = 25000;'); + + } catch (\Throwable $e) { + + Log::info('Couldn\'t set the max CTE recursion depth config.'); + } + if (config('database.default') === 'sqlite') { $date_interval = "date(date, '+1 day')"; - - } else if (config('database.default') === 'mysql') { - - DB::statement('SET GLOBAL cte_max_recursion_depth = 20000;'); } return DB::table(DB::raw("(