Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ce1c72a0bc | ||
|
|
10319ef728 |
@@ -5196,6 +5196,27 @@ final class CoreLibsDBIOTest extends TestCase
|
||||
SQL,
|
||||
'count' => 1,
|
||||
'convert' => false,
|
||||
],
|
||||
'update with case' => [
|
||||
'query' => <<<SQL
|
||||
UPDATE table_with_primary_key SET
|
||||
row_int = $1::INT,
|
||||
row_varchar = CASE WHEN row_int = 1 THEN $2 ELSE 'bar'::VARCHAR END
|
||||
WHERE
|
||||
row_varchar = $3
|
||||
SQL,
|
||||
'count' => 3,
|
||||
'convert' => false,
|
||||
],
|
||||
'select with case' => [
|
||||
'query' => <<<SQL
|
||||
SELECT row_int
|
||||
FROM table_with_primary_key
|
||||
WHERE
|
||||
row_varchar = CASE WHEN row_int = 1 THEN $1 ELSE $2 END
|
||||
SQL,
|
||||
'count' => 2,
|
||||
'convert' => false,
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
@@ -174,6 +174,26 @@ while (is_array($res = $db->dbReturnParams($query, [$query_value]))) {
|
||||
|
||||
echo "<hr>";
|
||||
|
||||
echo "<b>CASE part</b><br>";
|
||||
$query = <<<SQL
|
||||
UPDATE
|
||||
test_foo
|
||||
SET
|
||||
some_timestamp = NOW(),
|
||||
-- if not 1 set, else keep at one
|
||||
smallint_a = (CASE
|
||||
WHEN smallint_a <> 1 THEN $1
|
||||
ELSE 1::INT
|
||||
END)::INT
|
||||
WHERE
|
||||
string_a = $2
|
||||
SQL;
|
||||
echo "QUERY: <pre>" . $query . "</pre>";
|
||||
$res = $db->dbExecParams($query, [1, 'foobar']);
|
||||
print "ERROR: " . $db->dbGetLastError(true) . "<br>";
|
||||
|
||||
echo "<hr>";
|
||||
|
||||
// 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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -115,7 +115,7 @@ class AsymmetricAnonymousEncryption
|
||||
* @return string
|
||||
* @throws \UnexpectedValueException key pair empty
|
||||
* @throws \UnexpectedValueException invalid hex key pair
|
||||
* @throws \UnexpectedValueException key pair not correct size
|
||||
* @throws \RangeException key pair not correct size
|
||||
*/
|
||||
private function createKeyPair(
|
||||
#[\SensitiveParameter]
|
||||
@@ -147,7 +147,7 @@ class AsymmetricAnonymousEncryption
|
||||
* @return string
|
||||
* @throws \UnexpectedValueException public key empty
|
||||
* @throws \UnexpectedValueException invalid hex key
|
||||
* @throws \UnexpectedValueException invalid key length
|
||||
* @throws \RangeException invalid key length
|
||||
*/
|
||||
private function createPublicKey(?string $public_key): string
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user