From bf2853547e4ddedf84b9184a701b0cc63f07ea7f Mon Sep 17 00:00:00 2001 From: Dees Date: Tue, 8 Jun 2021 15:18:13 +0200 Subject: [PATCH] Cast JSON strings containing single quotes (#37619) --- .../Foundation/Testing/Concerns/InteractsWithDatabase.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithDatabase.php b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithDatabase.php index 86da0dcfd764..d01994e3ccff 100644 --- a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithDatabase.php +++ b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithDatabase.php @@ -134,7 +134,9 @@ public function castAsJson($value) $value = json_encode($value); } - return DB::raw("CAST('$value' AS JSON)"); + $value = DB::connection()->getPdo()->quote($value); + + return DB::raw("CAST($value AS JSON)"); } /**