IDEMPIERE-4881 CSS style anomaly - display logic (#786)

Fix regression (empty expression evaluation) introduce by previous
patch.

Pushing this through as the previous change set introduce a significant regression.
This commit is contained in:
hengsin 2021-07-20 21:47:17 +08:00 committed by GitHub
parent 0ce2bde958
commit 2975ff6429
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 0 deletions

View File

@ -138,6 +138,8 @@ public class EvaluationVisitor extends SimpleBooleanBaseVisitor<Object> {
private Boolean isEqual(SimpleBooleanParser.ComparatorExpressionContext ctx) {
Comparable left = asComparable(ctx.left);
Comparable right = asComparable(ctx.right);
if (left == null && right == null)
return Boolean.TRUE;
if (left == null || right == null)
return Boolean.FALSE;
if (left instanceof String && right instanceof String && !(ctx.right.getText().startsWith("'") && !(ctx.right.getText().startsWith("\"")))) {

View File

@ -543,6 +543,28 @@ public class LogicExpressionTest extends AbstractTestCase {
assertTrue(LogicEvaluator.evaluateLogic(evaluatee, expr));
}
@Test
public void testEmptyStringExpression() {
String expr = "@ColumnSQL@=''";
Env.setContext(Env.getCtx(), "ColumnSQL", (String)null);
assertTrue(LegacyLogicEvaluator.evaluateLogic(evaluatee, expr));
Env.setContext(Env.getCtx(), "ColumnSQL", (String)null);
assertTrue(LogicEvaluator.evaluateLogic(evaluatee, expr));
expr = "@ColumnSQL@!''";
Env.setContext(Env.getCtx(), "ColumnSQL", (String)null);
assertFalse(LegacyLogicEvaluator.evaluateLogic(evaluatee, expr));
Env.setContext(Env.getCtx(), "ColumnSQL", "now()");
assertTrue(LegacyLogicEvaluator.evaluateLogic(evaluatee, expr));
Env.setContext(Env.getCtx(), "ColumnSQL", (String)null);
assertFalse(LogicEvaluator.evaluateLogic(evaluatee, expr));
Env.setContext(Env.getCtx(), "ColumnSQL", "now()");
assertTrue(LogicEvaluator.evaluateLogic(evaluatee, expr));
}
private static class ContextEvaluatee implements Evaluatee {
@Override