diff --git a/4dev/tests/DB/CoreLibsDBIOTest.php b/4dev/tests/DB/CoreLibsDBIOTest.php index 14767292..ac6314d6 100644 --- a/4dev/tests/DB/CoreLibsDBIOTest.php +++ b/4dev/tests/DB/CoreLibsDBIOTest.php @@ -5196,6 +5196,27 @@ final class CoreLibsDBIOTest extends TestCase SQL, 'count' => 1, 'convert' => false, + ], + 'update with case' => [ + 'query' => << 3, + 'convert' => false, + ], + 'select with case' => [ + 'query' => << 2, + 'convert' => false, ] ]; } diff --git a/www/admin/class_test.db.query-placeholder.php b/www/admin/class_test.db.query-placeholder.php index 87b57971..c77cff6a 100644 --- a/www/admin/class_test.db.query-placeholder.php +++ b/www/admin/class_test.db.query-placeholder.php @@ -174,6 +174,26 @@ while (is_array($res = $db->dbReturnParams($query, [$query_value]))) { echo "
"; +echo "CASE part
"; +$query = << 1 THEN $1 + ELSE 1::INT + END)::INT +WHERE + string_a = $2 +SQL; +echo "QUERY:
" . $query . "
"; +$res = $db->dbExecParams($query, [1, 'foobar']); +print "ERROR: " . $db->dbGetLastError(true) . "
"; + +echo "
"; + // test connectors: = , <> () for query detection // convert placeholder tests @@ -237,7 +257,7 @@ SQL, SQL, 'params' => [1, 2, 3, 4, 5, 6], 'direction' => 'pg' - ] + ], ]; $db->dbSetConvertPlaceholder(true); diff --git a/www/lib/CoreLibs/DB/Support/ConvertPlaceholder.php b/www/lib/CoreLibs/DB/Support/ConvertPlaceholder.php index dff03788..484b7828 100644 --- a/www/lib/CoreLibs/DB/Support/ConvertPlaceholder.php +++ b/www/lib/CoreLibs/DB/Support/ConvertPlaceholder.php @@ -26,7 +26,9 @@ class ConvertPlaceholder . '&&|' // array overlap . '\-\|\-|' // range overlap for array . '[^-]-{1}|' // single -, used in JSON too - . '->|->>|#>|#>>|@>|<@|@@|@\?|\?{1}|\?\||\?&|#-'; //JSON searches, Array searchs, etc + . '->|->>|#>|#>>|@>|<@|@@|@\?|\?{1}|\?\||\?&|#-|' // JSON searches, Array searchs, etc + . 'THEN|ELSE' // command parts (CASE) + ; /** @var string the main regex including the pattern query split */ private const PATTERN_ELEMENT = '(?:\'.*?\')?\s*(?:' . self::PATTERN_QUERY_SPLIT . ')\s*'; /** @var string comment regex