diff --git a/core/dbobjectset.class.php b/core/dbobjectset.class.php index fe7336e95..b363541ad 100644 --- a/core/dbobjectset.class.php +++ b/core/dbobjectset.class.php @@ -738,14 +738,8 @@ class DBObjectSet { foreach($aVals as $sCode => $oExpr) { - if ($oExpr instanceof ScalarExpression) - { - $aConst[$sClassAlias][$sCode] = $oExpr->GetValue(); - } - else //Variable - { - $aConst[$sClassAlias][$sCode] = $aScalarArgs[$oExpr->GetName()]; - } + $oScalarExpr = $oExpr->GetAsScalar($aScalarArgs); + $aConst[$sClassAlias][$sCode] = $oScalarExpr->GetValue(); } } return $aConst; diff --git a/core/expression.class.inc.php b/core/expression.class.inc.php index 6450b6373..784376961 100644 --- a/core/expression.class.inc.php +++ b/core/expression.class.inc.php @@ -647,12 +647,29 @@ class VariableExpression extends UnaryExpression public function GetAsScalar($aArgs) { - $value = ''; + $value = null; if (array_key_exists($this->m_sName, $aArgs)) { $value = $aArgs[$this->m_sName]; } - else + elseif (($iPos = strpos($this->m_sName, '->')) !== false) + { + $sParamName = substr($this->m_sName, 0, $iPos); + if (array_key_exists($sParamName.'->object()', $aArgs)) + { + $sAttCode = substr($this->m_sName, $iPos + 2); + $oObj = $aArgs[$sParamName.'->object()']; + if ($sAttCode == 'id') + { + $value = $oObj->GetKey(); + } + else + { + $value = $oObj->Get($sAttCode); + } + } + } + if (is_null($value)) { throw new MissingQueryArgument('Missing query argument', array('expecting'=>$this->m_sName, 'available'=>array_keys($aArgs))); }