mirror of
https://github.com/dg/dibi.git
synced 2025-08-05 13:47:33 +02:00
HasmMap: fixed empty property name access
Introduced by 3891625cd1
PostgreSQL uses '::' syntax for type casting. Before this fix, HashMap returned ':\xff:' during SQL translation/substitution.
This commit is contained in:
committed by
David Grudl
parent
1b516786fb
commit
0c09ad97ca
@@ -58,7 +58,7 @@ final class HashMap extends HashMapBase
|
||||
{
|
||||
if ($nm == '') {
|
||||
$nm = "\xFF";
|
||||
return $this->$nm = $this->$nm ?? $this->getCallback()('');
|
||||
return isset($this->$nm) ? $this->$nm : $this->$nm = $this->getCallback()('');
|
||||
} else {
|
||||
return $this->$nm = $this->getCallback()($nm);
|
||||
}
|
||||
|
14
tests/dibi/HashMap.phpt
Normal file
14
tests/dibi/HashMap.phpt
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Tester\Assert;
|
||||
|
||||
require __DIR__ . '/bootstrap.php';
|
||||
|
||||
$hash = new Dibi\HashMap(function ($v) {
|
||||
return "b-$v-e";
|
||||
});
|
||||
|
||||
Assert::same('b-X-e', $hash->{'X'});
|
||||
Assert::same('b--e', $hash->{''});
|
Reference in New Issue
Block a user