From 329431d419f0fe5a82d054b820f906851fd6a319 Mon Sep 17 00:00:00 2001 From: Cesar Parra Date: Wed, 10 Dec 2025 10:59:14 -0400 Subject: [PATCH 1/2] Fix: enhance comparison operators to support Date and Datetime types --- .../main/src/interpreter/Interpreter.cls | 70 ++++++++++++++++--- 1 file changed, 61 insertions(+), 9 deletions(-) diff --git a/expression-src/main/src/interpreter/Interpreter.cls b/expression-src/main/src/interpreter/Interpreter.cls index 93c6857a..16e69bc1 100644 --- a/expression-src/main/src/interpreter/Interpreter.cls +++ b/expression-src/main/src/interpreter/Interpreter.cls @@ -139,20 +139,72 @@ public virtual with sharing class Interpreter implements Visitor { return ((Decimal)left).pow(Integer.valueOf(right)); } when GREATER { - checkNumberOperand(binary.operator, left, right); - return (Decimal)left > (Decimal)right; + // Check for numbers + if (left instanceof Decimal && right instanceof Decimal) { + return (Decimal)left > (Decimal)right; + } + + if (left instanceof Date && right instanceof Date) { + return (Date)left > (Date)right; + } + + if (left instanceof Datetime && right instanceof Datetime) { + return (Datetime)left > (Datetime)right; + } + + throw new Exceptions.RuntimeException( + binary.operator, + 'Error executing ' + binary.operator.lexeme + ' operator: operands must be numbers, dates, or datetimes.' + ); } when GREATER_EQUAL { - checkNumberOperand(binary.operator, left, right); - return (Decimal)left >= (Decimal)right; + if (left instanceof Decimal && right instanceof Decimal) { + return (Decimal)left >= (Decimal)right; + } + + if (left instanceof Date && right instanceof Date) { + return (Date)left >= (Date)right; + } + + if (left instanceof Datetime && right instanceof Datetime) { + return (Datetime)left >= (Datetime)right; + } + + throw new Exceptions.RuntimeException( + binary.operator, + 'Error executing ' + binary.operator.lexeme + ' operator: operands must be numbers, dates, or datetimes.' + ); } when LESS { - checkNumberOperand(binary.operator, left, right); - return (Decimal)left < (Decimal)right; + if (left instanceof Decimal && right instanceof Decimal) { + return (Decimal)left < (Decimal)right; + } + + if (left instanceof Date && right instanceof Date) { + return (Date)left < (Date)right; + } + + if (left instanceof Datetime && right instanceof Datetime) { + return (Datetime)left < (Datetime)right; + } + + throw new Exceptions.RuntimeException( + binary.operator, + 'Error executing ' + binary.operator.lexeme + ' operator: operands must be numbers, dates, or datetimes.' + ); } when LESS_EQUAL { - checkNumberOperand(binary.operator, left, right); - return (Decimal)left <= (Decimal)right; + if (left instanceof Decimal && right instanceof Decimal) { + return (Decimal)left <= (Decimal)right; + } + + if (left instanceof Date && right instanceof Date) { + return (Date)left <= (Date)right; + } + + if (left instanceof Datetime && right instanceof Datetime) { + return (Datetime)left <= (Datetime)right; + } } when EQUAL, EQUAL_EQUAL { return left == right; @@ -567,7 +619,7 @@ public virtual with sharing class Interpreter implements Visitor { return new ShouldNotAdd(); } - + public Object visit(Expr.PipelineFunction pipelineFunction) { throw new Exceptions.UnknownException( 'Pipelines should first be desugared by the PipeResolver before reaching the Interpreter.' From 14a0e04c826f2d8cc8e2d27408fdcaf3e953de26 Mon Sep 17 00:00:00 2001 From: Cesar Parra Date: Wed, 10 Dec 2025 11:27:22 -0400 Subject: [PATCH 2/2] Releasing new version --- docs/public/packages.json | 2 +- sfdx-project_packaging.json | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/public/packages.json b/docs/public/packages.json index f64595d0..a5cd09b5 100644 --- a/docs/public/packages.json +++ b/docs/public/packages.json @@ -1,4 +1,4 @@ { - "packageId": "04tRb000003z0hJIAQ", + "packageId": "04tRb0000042CNlIAM", "componentPackageId": "04tRb0000012Mv8IAE" } diff --git a/sfdx-project_packaging.json b/sfdx-project_packaging.json index 14836f71..bac1a7ab 100644 --- a/sfdx-project_packaging.json +++ b/sfdx-project_packaging.json @@ -3,7 +3,7 @@ { "package": "Expression", "versionName": "Version 1.36", - "versionNumber": "1.44.0.NEXT", + "versionNumber": "1.45.0.NEXT", "path": "expression-src", "default": false, "versionDescription": "Expression core language", @@ -73,6 +73,7 @@ "Expression@1.41.0-1": "04tRb000003tVPdIAM", "Expression@1.42.0-1": "04tRb000003xe4XIAQ", "Expression@1.43.0-1": "04tRb000003xzXCIAY", - "Expression@1.44.0-1": "04tRb000003z0hJIAQ" + "Expression@1.44.0-1": "04tRb000003z0hJIAQ", + "Expression@1.45.0-1": "04tRb0000042CNlIAM" } } \ No newline at end of file