From 37f3dd7a4b7d2810e72e44925d96eb4b9bc39507 Mon Sep 17 00:00:00 2001
From: Daniel Leaver <daniel.leaver@neotechnology.com>
Date: Tue, 5 Jul 2022 16:19:26 +0100
Subject: [PATCH] Revert "Fix CASE when comparing null values ()" ()

This reverts commit b44bb4e01e4b1ebb71f6da1695c864dd84d3562e.
---
 .../commands/expressions/SimpleCase.scala     |  2 +-
 .../features/CaseExpression.feature           | 58 -------------------
 .../main/java/org/neo4j/values/AnyValue.java  | 12 ----
 3 files changed, 1 insertion(+), 71 deletions(-)

diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/commands/expressions/SimpleCase.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/commands/expressions/SimpleCase.scala
index d6ec9436660..3bb8fd2c418 100644
--- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/commands/expressions/SimpleCase.scala
+++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/commands/expressions/SimpleCase.scala
@@ -31,7 +31,7 @@ case class SimpleCase(expression: Expression, alternatives: Seq[(Expression, Exp
     val value = expression(row, state)
 
     val matchingExpression: Option[Expression] = alternatives collectFirst {
-      case (exp, res) if exp(row, state).equalsWithNoValueCheck(value) => res
+      case (exp, res) if exp(row, state) == value => res
     }
 
     matchingExpression match {
diff --git a/community/cypher/spec-suite-tools/src/test/resources/acceptance/features/CaseExpression.feature b/community/cypher/spec-suite-tools/src/test/resources/acceptance/features/CaseExpression.feature
index 06ebb1f9ba8..94a06571f78 100644
--- a/community/cypher/spec-suite-tools/src/test/resources/acceptance/features/CaseExpression.feature
+++ b/community/cypher/spec-suite-tools/src/test/resources/acceptance/features/CaseExpression.feature
@@ -330,61 +330,3 @@ Feature: CaseExpression
       | count  |
       | 1      |
     And no side effects
-
-  Scenario: When given null, any WHEN containing null should not match as null == null = null
-    When executing query:
-      """
-      RETURN
-      CASE null
-          WHEN null THEN true
-          ELSE false
-      END AS res
-      """
-    Then the result should be, in any order:
-      | res   |
-      | false |
-    And no side effects
-
-
-  Scenario: When given null = null as a comparison it should evaluate to false
-    When executing query:
-      """
-      RETURN
-      CASE
-          WHEN null = null THEN true
-          ELSE false
-      END AS res
-      """
-    Then the result should be, in any order:
-      | res   |
-      | false |
-    And no side effects
-
-
-  Scenario: When given null IS null as a comparison it should evaluate to true
-    When executing query:
-      """
-      RETURN
-      CASE
-          WHEN null IS NULL THEN true
-          ELSE false
-      END AS res
-      """
-    Then the result should be, in any order:
-      | res   |
-      | true  |
-    And no side effects
-
-
-  Scenario: When given null and no default, null should be returned
-    When executing query:
-      """
-      RETURN
-      CASE null
-          WHEN null THEN true
-      END AS res
-      """
-    Then the result should be, in any order:
-      | res   |
-      | null  |
-    And no side effects
diff --git a/community/values/src/main/java/org/neo4j/values/AnyValue.java b/community/values/src/main/java/org/neo4j/values/AnyValue.java
index 33882383113..5df2b6dd6d5 100644
--- a/community/values/src/main/java/org/neo4j/values/AnyValue.java
+++ b/community/values/src/main/java/org/neo4j/values/AnyValue.java
@@ -23,7 +23,6 @@ import org.neo4j.memory.Measurable;
 import org.neo4j.values.storable.FloatingPointValue;
 import org.neo4j.values.storable.NumberValue;
 import org.neo4j.values.storable.ValueRepresentation;
-import org.neo4j.values.storable.Values;
 
 public abstract class AnyValue implements Measurable
 {
@@ -35,17 +34,6 @@ public abstract class AnyValue implements Measurable
         return this == other || other != null && equalTo( other );
     }
 
-    // In Cypher RETURN null = null; returns null. Therefore, in a binary equals we
-    // sometimes need to return false when matching e.g CASE null WHEN null THEN... shouldn't match on null
-    public boolean equalsWithNoValueCheck( Object other )
-    {
-        if ( this == Values.NO_VALUE && other == Values.NO_VALUE )
-        {
-            return false;
-        }
-        return this == other || other != null && equalTo(other);
-    }
-
     @Override
     public final int hashCode()
     {
-- 
GitLab