mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-19 07:12:26 +02:00
N°5791 - Obsolescence condition containing IN makes object creation fail
This commit is contained in:
@@ -575,6 +575,9 @@ class BinaryExpression extends Expression
|
||||
case 'LIKE':
|
||||
$sType = 'like';
|
||||
break;
|
||||
case 'IN':
|
||||
$sType = 'in';
|
||||
break;
|
||||
default:
|
||||
throw new Exception("Operator '$sOperator' not yet supported");
|
||||
}
|
||||
@@ -641,6 +644,9 @@ class BinaryExpression extends Expression
|
||||
$sEscaped = str_replace(array('%', '_', '\\\\.*', '\\\\.'), array('.*', '.', '%', '_'), $sEscaped);
|
||||
$result = (int) preg_match("/$sEscaped/i", $mLeft);
|
||||
break;
|
||||
case 'in':
|
||||
$result = in_array($mLeft, $mRight);
|
||||
break;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
@@ -2250,7 +2256,12 @@ class ListExpression extends Expression
|
||||
*/
|
||||
public function Evaluate(array $aArgs)
|
||||
{
|
||||
throw new Exception('list expression not yet supported');
|
||||
//throw new Exception('list expression not yet supported');
|
||||
$aResult = [];
|
||||
foreach ($this->m_aExpressions as $oExpressions) {
|
||||
$aResult[] = $oExpressions->Evaluate($aArgs);
|
||||
}
|
||||
return $aResult;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -90,7 +90,7 @@ class ExpressionEvaluateTest extends ItopDataTestCase
|
||||
{
|
||||
$aExpressions = array(
|
||||
// Test case to isolate for troubleshooting purposes
|
||||
array('1+1', 2),
|
||||
array("'a' IN ('a', 'b')", true),
|
||||
);
|
||||
}
|
||||
else
|
||||
@@ -141,6 +141,9 @@ class ExpressionEvaluateTest extends ItopDataTestCase
|
||||
array('"2020-06-12 17:35:13" < "2020-06-12"', 0),
|
||||
array('"2020-06-12 00:00:00" = "2020-06-12"', 0),
|
||||
|
||||
// IN operator
|
||||
array("'a' IN ('a', 'b')", true),
|
||||
|
||||
// Logical operators
|
||||
array('0 AND 0', 0),
|
||||
array('1 AND 0', 0),
|
||||
|
||||
Reference in New Issue
Block a user