From 37367db878a324e5b90f7e4bfec4a66c1518ebc9 Mon Sep 17 00:00:00 2001 From: Clemens Schwaighofer Date: Mon, 7 Apr 2025 19:44:18 +0900 Subject: [PATCH] Fix regex for $$ PostgresSQL string in convert placeholder --- 4dev/tests/DB/CoreLibsDBIOTest.php | 36 +++++++++++++++++++ .../DB/Support/ConvertPlaceholder.php | 2 +- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/4dev/tests/DB/CoreLibsDBIOTest.php b/4dev/tests/DB/CoreLibsDBIOTest.php index d4e62d90..4ed9cabd 100644 --- a/4dev/tests/DB/CoreLibsDBIOTest.php +++ b/4dev/tests/DB/CoreLibsDBIOTest.php @@ -135,6 +135,7 @@ final class CoreLibsDBIOTest extends TestCase } // check if they already exist, drop them if ($db->dbShowTableMetaData('table_with_primary_key') !== false) { + $db->dbExec("CREATE EXTENSION IF NOT EXISTS pgcrypto"); $db->dbExec("DROP TABLE table_with_primary_key"); $db->dbExec("DROP TABLE table_without_primary_key"); $db->dbExec("DROP TABLE test_meta"); @@ -5309,6 +5310,38 @@ final class CoreLibsDBIOTest extends TestCase 'count' => 2, 'convert' => false, ], + // special $$ string case + 'text string, with $ placehoders that could be seen as $$ string' => [ + 'query' => << 6, + 'convert' => false, + ], + // NOTE, in SQL heredoc we cannot write $$ strings parts + 'text string, with $ placehoders are in $$ strings' => [ + 'query' => ' + SELECT row_int + FROM table_with_primary_key + WHERE + row_varchar = $$some string$$ OR + row_varchar = $tag$some string$tag$ OR + row_varchar = $btag$some $1 string$btag$ OR + row_varchar = $btag$some $1 $subtag$ something $subtag$string$btag$ OR + row_varchar = $1 + ', + 'count' => 1, + 'convert' => false, + ], // a text string with escaped quite 'text string, with escaped quote' => [ 'query' => << false, ] ]; + $string = <<