diff --git a/arex-compare-core/pom.xml b/arex-compare-core/pom.xml
index ce338ed..f0c843e 100644
--- a/arex-compare-core/pom.xml
+++ b/arex-compare-core/pom.xml
@@ -5,7 +5,7 @@
arex-compare-parent
com.arextest
- 0.2.16
+ 0.2.17
4.0.0
diff --git a/arex-compare-core/src/main/java/com/arextest/diff/compare/ArrayCompare.java b/arex-compare-core/src/main/java/com/arextest/diff/compare/ArrayCompare.java
index ee25fbc..38d22d6 100644
--- a/arex-compare-core/src/main/java/com/arextest/diff/compare/ArrayCompare.java
+++ b/arex-compare-core/src/main/java/com/arextest/diff/compare/ArrayCompare.java
@@ -6,6 +6,7 @@
import com.arextest.diff.handler.log.register.LogRegister;
import com.arextest.diff.model.compare.CompareContext;
import com.arextest.diff.model.compare.IndexPair;
+import com.arextest.diff.model.enumeration.ParentNodeType;
import com.arextest.diff.model.log.NodeEntity;
import com.arextest.diff.utils.ListUti;
import com.fasterxml.jackson.databind.node.ArrayNode;
@@ -55,7 +56,8 @@ public static void arrayCompare(Object obj1, Object obj2, CompareContext compare
boolean rightExist = false;
if (correspondRightIndex == -1) {
- LogRegister.register(element1, element2, LogMarker.RIGHT_ARRAY_MISSING_KEY, compareContext);
+ compareContext.parentNodeType = ParentNodeType.ARRAY;
+ GenericCompare.jsonCompare(element1, element2, compareContext);
} else {
element2 = obj2Array.get(correspondRightIndex);
rightExist = true;
@@ -70,6 +72,7 @@ public static void arrayCompare(Object obj1, Object obj2, CompareContext compare
compareContext.pkListIndexPair,
compareContext.currentNodeLeft);
if (needCompare && element1 != null && element2 != null) {
+ compareContext.parentNodeType = ParentNodeType.ARRAY;
GenericCompare.jsonCompare(element1, element2, compareContext);
}
}
@@ -98,7 +101,8 @@ public static void arrayCompare(Object obj1, Object obj2, CompareContext compare
Object element2 = obj2Array.get(i);
boolean leftExist = false;
if (correspondLeftIndex == -1) {
- LogRegister.register(element1, element2, LogMarker.LEFT_ARRAY_MISSING_KEY, compareContext);
+ compareContext.parentNodeType = ParentNodeType.ARRAY;
+ GenericCompare.jsonCompare(element1, element2, compareContext);
} else {
element1 = obj1Array.get(correspondLeftIndex);
leftExist = true;
@@ -111,6 +115,7 @@ public static void arrayCompare(Object obj1, Object obj2, CompareContext compare
compareContext.pkListIndexPair,
compareContext.currentNodeRight);
if (needCompare && element1 != null && element2 != null) {
+ compareContext.parentNodeType = ParentNodeType.ARRAY;
GenericCompare.jsonCompare(element1, element2, compareContext);
}
}
diff --git a/arex-compare-core/src/main/java/com/arextest/diff/compare/GenericCompare.java b/arex-compare-core/src/main/java/com/arextest/diff/compare/GenericCompare.java
index abe800c..e6acaa2 100644
--- a/arex-compare-core/src/main/java/com/arextest/diff/compare/GenericCompare.java
+++ b/arex-compare-core/src/main/java/com/arextest/diff/compare/GenericCompare.java
@@ -3,6 +3,7 @@
import com.arextest.diff.handler.log.LogMarker;
import com.arextest.diff.handler.log.register.LogRegister;
import com.arextest.diff.model.compare.CompareContext;
+import com.arextest.diff.model.enumeration.ParentNodeType;
import com.arextest.diff.model.log.NodeEntity;
import com.arextest.diff.utils.IgnoreUtil;
import com.arextest.diff.utils.ListUti;
@@ -10,6 +11,7 @@
import com.fasterxml.jackson.databind.node.NullNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import java.util.List;
+import java.util.Objects;
public class GenericCompare {
@@ -34,8 +36,9 @@ public static void jsonCompare(Object obj1, Object obj2, CompareContext compareC
}
// not compare by exclusions
- if (IgnoreUtil.ignoreProcessor(fuzzyPath, currentNode, compareContext.exclusions,
- compareContext.expressionExclusions, compareContext.ignoreNodeSet)) {
+ if (IgnoreUtil.ignoreProcessor(fuzzyPath, compareContext.currentNodeLeft,
+ compareContext.currentNodeRight, compareContext.exclusions,
+ compareContext.conditionExclusions, compareContext.ignoreNodeSet)) {
return;
}
@@ -43,10 +46,16 @@ public static void jsonCompare(Object obj1, Object obj2, CompareContext compareC
if (obj1 == null && obj2 == null) {
return;
} else if (obj1 == null) {
- LogRegister.register(obj1, obj2, LogMarker.LEFT_OBJECT_MISSING, compareContext);
+ LogRegister.register(obj1, obj2,
+ Objects.equals(compareContext.parentNodeType, ParentNodeType.OBJECT)
+ ? LogMarker.LEFT_OBJECT_MISSING
+ : LogMarker.LEFT_ARRAY_MISSING, compareContext);
return;
} else if (obj2 == null) {
- LogRegister.register(obj1, obj2, LogMarker.RIGHT_OBJECT_MISSING, compareContext);
+ LogRegister.register(obj1, obj2,
+ Objects.equals(compareContext.parentNodeType, ParentNodeType.OBJECT)
+ ? LogMarker.LEFT_OBJECT_MISSING
+ : LogMarker.RIGHT_ARRAY_MISSING, compareContext);
return;
}
diff --git a/arex-compare-core/src/main/java/com/arextest/diff/compare/ObjectCompare.java b/arex-compare-core/src/main/java/com/arextest/diff/compare/ObjectCompare.java
index c0a0e0f..8e2d4da 100644
--- a/arex-compare-core/src/main/java/com/arextest/diff/compare/ObjectCompare.java
+++ b/arex-compare-core/src/main/java/com/arextest/diff/compare/ObjectCompare.java
@@ -1,6 +1,7 @@
package com.arextest.diff.compare;
import com.arextest.diff.model.compare.CompareContext;
+import com.arextest.diff.model.enumeration.ParentNodeType;
import com.arextest.diff.model.log.NodeEntity;
import com.arextest.diff.utils.JacksonHelperUtil;
import com.arextest.diff.utils.ListUti;
@@ -34,6 +35,7 @@ public static void objectCompare(Object obj1, Object obj2, CompareContext compar
compareContext.currentNodeRight.add(new NodeEntity(fieldName, 0));
}
+ compareContext.parentNodeType = ParentNodeType.OBJECT;
GenericCompare.jsonCompare(obj1FieldValue, obj2FieldValue, compareContext);
ListUti.removeLast(compareContext.currentNodeLeft);
@@ -57,6 +59,7 @@ public static void objectCompare(Object obj1, Object obj2, CompareContext compar
compareContext.currentNodeLeft.add(new NodeEntity(fieldName, 0));
}
+ compareContext.parentNodeType = ParentNodeType.OBJECT;
GenericCompare.jsonCompare(obj1FieldValue, obj2FieldValue, compareContext);
if (leftExist) {
diff --git a/arex-compare-core/src/main/java/com/arextest/diff/eigen/EigenHandler.java b/arex-compare-core/src/main/java/com/arextest/diff/eigen/EigenHandler.java
index dddec1c..f74ada2 100644
--- a/arex-compare-core/src/main/java/com/arextest/diff/eigen/EigenHandler.java
+++ b/arex-compare-core/src/main/java/com/arextest/diff/eigen/EigenHandler.java
@@ -10,9 +10,10 @@
import com.arextest.diff.model.pathparse.ExpressionNodeEntity;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
-import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
import java.util.Objects;
public class EigenHandler {
@@ -41,13 +42,13 @@ public EigenResult doHandler(RulesConfig rulesConfig) {
obj = null;
}
- LinkedList> expressionExclusions =
- jsonPathExpressionHandler.doMultiExpressionParse(rulesConfig.getExpressionExclusions(),
+ List> expressionExclusions = new LinkedList<>();
+ Map, LinkedList>> listLinkedListMap =
+ jsonPathExpressionHandler.doMultiExpressionParse(
+ rulesConfig.getExpressionExclusions(),
obj);
- if (expressionExclusions != null) {
- rulesConfig.setExpressionExclusions(new ArrayList<>(expressionExclusions));
- }
-
+ listLinkedListMap.values().forEach(expressionExclusions::addAll);
+ rulesConfig.setExpressionExclusions(expressionExclusions);
return eigenMapCalculate.doCalculate(obj, rulesConfig, new HashMap<>());
}
diff --git a/arex-compare-core/src/main/java/com/arextest/diff/eigen/EigenMapCalculate.java b/arex-compare-core/src/main/java/com/arextest/diff/eigen/EigenMapCalculate.java
index 98fb276..1a6a9dc 100644
--- a/arex-compare-core/src/main/java/com/arextest/diff/eigen/EigenMapCalculate.java
+++ b/arex-compare-core/src/main/java/com/arextest/diff/eigen/EigenMapCalculate.java
@@ -12,7 +12,6 @@
import java.time.Instant;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
-import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
@@ -54,7 +53,8 @@ private void doCalculateJsonNode(Object obj, CalculateContext calculateContext,
Map eigenMap) {
// ignore by node name and node path
- if (IgnoreUtil.ignoreProcessor(calculateContext.nodePath, calculateContext.currentNodeEntity,
+ if (IgnoreUtil.ignoreProcessorEngine(calculateContext.nodePath,
+ calculateContext.currentNodeEntity,
calculateContext.exclusions, calculateContext.expressionExclusions,
calculateContext.ignoreNodeSet)) {
return;
diff --git a/arex-compare-core/src/main/java/com/arextest/diff/handler/CompareHandler.java b/arex-compare-core/src/main/java/com/arextest/diff/handler/CompareHandler.java
index 101a94a..7eeb7ab 100644
--- a/arex-compare-core/src/main/java/com/arextest/diff/handler/CompareHandler.java
+++ b/arex-compare-core/src/main/java/com/arextest/diff/handler/CompareHandler.java
@@ -29,7 +29,7 @@ public List doHandler(RulesConfig rulesConfig, KeyComputeResponse key
compareContext.setResponseReferences(keyComputeResponse.getAllReferenceEntities());
compareContext.exclusions = rulesConfig.getExclusions();
- compareContext.expressionExclusions = rulesConfig.getExpressionExclusions();
+ compareContext.conditionExclusions = rulesConfig.getConditionExclusions();
compareContext.ignoreNodeSet = rulesConfig.getIgnoreNodeSet();
compareContext.notDistinguishNullAndEmpty = rulesConfig.isNullEqualsEmpty();
diff --git a/arex-compare-core/src/main/java/com/arextest/diff/handler/parse/sqlparse/SqlParse.java b/arex-compare-core/src/main/java/com/arextest/diff/handler/parse/sqlparse/SqlParse.java
index a6355f2..4a0ffad 100644
--- a/arex-compare-core/src/main/java/com/arextest/diff/handler/parse/sqlparse/SqlParse.java
+++ b/arex-compare-core/src/main/java/com/arextest/diff/handler/parse/sqlparse/SqlParse.java
@@ -76,6 +76,9 @@ public ParsedResult sqlParse(ObjectNode jsonObj, boolean nameToLower) {
return new ParsedResult(null, false);
}
+ // additional: Handling multiple selections
+ databaseBody = processMultipleSelect(databaseBody);
+
boolean successParse = true;
ArrayNode parsedSql = JacksonHelperUtil.getArrayNode();
List isSelect = new ArrayList<>();
@@ -245,6 +248,41 @@ private void fillOriginalSql(ObjectNode objectNode, JsonNode databaseBody) {
objectNode.set(DbParseConstants.PARSED_SQL, parsedSql);
}
+ private JsonNode processMultipleSelect(JsonNode databaseBody) {
+ JsonNode result = databaseBody;
+ if (databaseBody instanceof TextNode) {
+ String sql = databaseBody.asText();
+ if (sql.contains(";")) {
+ String[] sqls = sql.split(";");
+ ArrayNode arrayNode = JacksonHelperUtil.getArrayNode();
+ for (String s : sqls) {
+ if (!startsWithSelect(s)) {
+ break;
+ }
+ arrayNode.add(s);
+ }
+ result = arrayNode;
+ }
+
+ }
+ return result;
+ }
+
+ public static boolean startsWithSelect(String str) {
+ if (str == null) {
+ return false;
+ }
+ int len = str.length();
+ int i = 0;
+ // Skip leading whitespace
+ while (i < len && Character.isWhitespace(str.charAt(i))) {
+ i++;
+ }
+ // Check if the remaining string starts with "select" or "SELECT"
+ return str.regionMatches(true, i, "select", 0, 6);
+ }
+
+
private static class ParsedResult {
private List isSelect;
diff --git a/arex-compare-core/src/main/java/com/arextest/diff/handler/pathparse/JsonPathExpressionHandler.java b/arex-compare-core/src/main/java/com/arextest/diff/handler/pathparse/JsonPathExpressionHandler.java
index 2f3a7e0..c94f231 100644
--- a/arex-compare-core/src/main/java/com/arextest/diff/handler/pathparse/JsonPathExpressionHandler.java
+++ b/arex-compare-core/src/main/java/com/arextest/diff/handler/pathparse/JsonPathExpressionHandler.java
@@ -11,9 +11,12 @@
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.fasterxml.jackson.databind.node.TextNode;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
@@ -29,16 +32,20 @@ public class JsonPathExpressionHandler {
public void doExpressionParse(RulesConfig rulesConfig,
Object baseObj, Object testObj) throws ExecutionException, InterruptedException {
- Set> result = new HashSet<>();
+ Map>, LinkedList>>
+ conditionExclusions = null;
+
try {
List> expressionExclusions = rulesConfig.getExpressionExclusions();
- CompletableFuture>> future1 = CompletableFuture.supplyAsync(
+ CompletableFuture