From 82c53b6716585ac9f22e86a2239013da44feed16 Mon Sep 17 00:00:00 2001 From: Pete Frost Date: Wed, 14 Aug 2024 22:03:27 +0100 Subject: [PATCH] Make SQLiteProcessor cope with '/' in column names --- .../Database/Query/Processors/SQLiteProcessor.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Database/Query/Processors/SQLiteProcessor.php b/src/Illuminate/Database/Query/Processors/SQLiteProcessor.php index 5ce6ecac48f7..82d5a321b3da 100644 --- a/src/Illuminate/Database/Query/Processors/SQLiteProcessor.php +++ b/src/Illuminate/Database/Query/Processors/SQLiteProcessor.php @@ -20,8 +20,10 @@ public function processColumns($results, $sql = '') $type = strtolower($result->type); + $safeName - preg_quote($result->name, '/'); + $collation = preg_match( - '/\b'.preg_quote($result->name).'\b[^,(]+(?:\([^()]+\)[^,]*)?(?:(?:default|check|as)\s*(?:\(.*?\))?[^,]*)*collate\s+["\'`]?(\w+)/i', + '/\b'.$safeName.'\b[^,(]+(?:\([^()]+\)[^,]*)?(?:(?:default|check|as)\s*(?:\(.*?\))?[^,]*)*collate\s+["\'`]?(\w+)/i', $sql, $matches ) === 1 ? strtolower($matches[1]) : null; @@ -29,7 +31,7 @@ public function processColumns($results, $sql = '') $isGenerated = in_array($result->extra, [2, 3]); $expression = $isGenerated && preg_match( - '/\b'.preg_quote($result->name).'\b[^,]+\s+as\s+\(((?:[^()]+|\((?:[^()]+|\([^()]*\))*\))*)\)/i', + '/\b'.$safeName.'\b[^,]+\s+as\s+\(((?:[^()]+|\((?:[^()]+|\([^()]*\))*\))*)\)/i', $sql, $matches ) === 1 ? $matches[1] : null;