From 0c09ad97cab99711614ce707b71a461f6bba304e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20H=C5=AFla?= Date: Fri, 4 Aug 2017 14:06:08 +0200 Subject: [PATCH] HasmMap: fixed empty property name access Introduced by 3891625cd1a1cb063486b3d62f3d2846699c906a PostgreSQL uses '::' syntax for type casting. Before this fix, HashMap returned ':\xff:' during SQL translation/substitution. --- src/Dibi/HashMap.php | 2 +- tests/dibi/HashMap.phpt | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 tests/dibi/HashMap.phpt diff --git a/src/Dibi/HashMap.php b/src/Dibi/HashMap.php index eef445f1..bdf1b693 100644 --- a/src/Dibi/HashMap.php +++ b/src/Dibi/HashMap.php @@ -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); } diff --git a/tests/dibi/HashMap.phpt b/tests/dibi/HashMap.phpt new file mode 100644 index 00000000..f14cfc1e --- /dev/null +++ b/tests/dibi/HashMap.phpt @@ -0,0 +1,14 @@ +{'X'}); +Assert::same('b--e', $hash->{''});