From 96b04c125d9547212bd07ab8db91f4a6d205f7d4 Mon Sep 17 00:00:00 2001 From: Anton Vasetenkov Date: Tue, 23 Jul 2024 19:17:17 +1200 Subject: [PATCH] Fix list equality logic --- .../src/test/java/org/hl7/fhirpath/CQLOperationsR4Test.java | 1 - .../resources/org/hl7/fhirpath/cql/CqlListOperatorsTest.xml | 2 +- .../main/java/org/opencds/cqf/cql/engine/runtime/CqlList.java | 3 +++ .../opencds/cqf/cql/engine/execution/ListOperatorsTest.java | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Src/java/engine-fhir/src/test/java/org/hl7/fhirpath/CQLOperationsR4Test.java b/Src/java/engine-fhir/src/test/java/org/hl7/fhirpath/CQLOperationsR4Test.java index de0b95721..3ab7d205b 100644 --- a/Src/java/engine-fhir/src/test/java/org/hl7/fhirpath/CQLOperationsR4Test.java +++ b/Src/java/engine-fhir/src/test/java/org/hl7/fhirpath/CQLOperationsR4Test.java @@ -108,7 +108,6 @@ public static Object[][] dataMethod() { "cql/CqlListOperatorsTest/Equivalent/Equivalent123AndABC", "cql/CqlListOperatorsTest/Equivalent/Equivalent123AndString123", "cql/CqlListOperatorsTest/Equivalent/EquivalentABCAnd123", - "cql/CqlListOperatorsTest/Flatten/FlattenListNullAndNull", "cql/CqlListOperatorsTest/NotEqual/NotEqual123AndABC", "cql/CqlListOperatorsTest/NotEqual/NotEqual123AndString123", "cql/CqlListOperatorsTest/NotEqual/NotEqualABCAnd123", diff --git a/Src/java/engine-fhir/src/test/resources/org/hl7/fhirpath/cql/CqlListOperatorsTest.xml b/Src/java/engine-fhir/src/test/resources/org/hl7/fhirpath/cql/CqlListOperatorsTest.xml index ce3bc6364..2eef803f7 100644 --- a/Src/java/engine-fhir/src/test/resources/org/hl7/fhirpath/cql/CqlListOperatorsTest.xml +++ b/Src/java/engine-fhir/src/test/resources/org/hl7/fhirpath/cql/CqlListOperatorsTest.xml @@ -129,7 +129,7 @@ {null} = {null} - null + true {} as List<String> = null diff --git a/Src/java/engine/src/main/java/org/opencds/cqf/cql/engine/runtime/CqlList.java b/Src/java/engine/src/main/java/org/opencds/cqf/cql/engine/runtime/CqlList.java index 63dccb26d..f4a40f4b8 100644 --- a/Src/java/engine/src/main/java/org/opencds/cqf/cql/engine/runtime/CqlList.java +++ b/Src/java/engine/src/main/java/org/opencds/cqf/cql/engine/runtime/CqlList.java @@ -109,6 +109,9 @@ public static Boolean equal(Iterable left, Iterable right, State state) { if (leftObject instanceof Iterable && rightObject instanceof Iterable) { return equal((Iterable) leftObject, (Iterable) rightObject, state); } + if (leftObject == null && rightObject == null) { + return true; + } Boolean elementEquals = EqualEvaluator.equal(leftObject, rightObject, state); if (elementEquals == null || !elementEquals) { return elementEquals; diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/ListOperatorsTest.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/ListOperatorsTest.java index 7eb0045e3..18ed93304 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/ListOperatorsTest.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/ListOperatorsTest.java @@ -164,7 +164,7 @@ void all_interval_operators() { assertThat(((List) value).size(), is(2)); value = results.forExpression("EqualNullNull").value(); - assertThat(value, is(nullValue())); + assertThat(value, is(true)); value = results.forExpression("EqualEmptyListNull").value(); assertThat(value, is(nullValue()));