Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: for comparing only fields with the same name, only nesting one level down #57

Merged
merged 2 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion arex-compare-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>arex-compare-parent</artifactId>
<groupId>com.arextest</groupId>
<version>0.2.12</version>
<version>0.2.13</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ private boolean isIgnorePath(List<String> fuzzyPath) {
int fuzzyPathSize = fuzzyPath.size();
int ignorePathSize = ignoreNodePath.size();

if (ignorePathSize < fuzzyPathSize) {
// such as parameters/parammap vs parameters
if (fuzzyPathSize - ignorePathSize == 1) {
boolean flag = true;
for (int i = 0; i < ignorePathSize; i++) {
if (!Objects.equals(ignoreNodePath.get(i), fuzzyPath.get(i))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ public void testExpressionNodeIgnore() {
+ " },\n"
+ " {\n"
+ " \"info\": {\n"
+ " \"name\": \"apple\"\n"
+ " \"name\": \"tiktok\"\n"
+ " },\n"
+ " \"age\": 20\n"
+ " }\n"
Expand Down Expand Up @@ -773,5 +773,41 @@ public void testTransFormConfigTest() {
Assertions.assertEquals(1, result.getLogs().size());
}

@Test
public void testParmeter() {
CompareSDK sdk = new CompareSDK();
sdk.getGlobalOptions().putOnlyCompareCoincidentColumn(true);

String str1 = "{\n"
+ " \"parameters\": {\n"
+ " \"parammap\": \"{\\\"link_type\\\":1,\\\"token\\\":\\\"1\\\"}\",\n"
+ " \"tablename\": \"table\"\n"
+ " },\n"
+ " \"body\": \"insert into log (table_name, param_map) values (?, ?)\",\n"
+ " \"dbname\": \"\"\n"
+ " }\n"
+ " ]\n"
+ "}";

String str2 = "{\n"
+ " \"parameters\": {\n"
+ " \"parammap\": \"{\\\"link_type\\\":1}\",\n"
+ " \"tablename\": \"table\"\n"
+ " },\n"
+ " \"body\": \"insert into log (table_name, param_map) values (?, ?)\",\n"
+ " \"dbname\": \"\"\n"
+ " }\n"
+ " ]\n"
+ "}";

CompareOptions compareOptions = CompareOptions.options();
compareOptions.putExclusions(Arrays.asList("body"));
compareOptions.putCategoryType(CategoryType.DATABASE);
compareOptions.putOnlyCompareCoincidentColumn(true);

CompareResult result = sdk.compare(str1, str2, compareOptions);
Assertions.assertEquals(1, result.getLogs().size());
}


}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>com.arextest</groupId>
<artifactId>arex-compare-parent</artifactId>
<packaging>pom</packaging>
<version>0.2.12</version>
<version>0.2.13</version>
<modules>
<module>arex-compare-extension</module>
<module>arex-compare-core</module>
Expand Down
Loading