Skip to content

Commit

Permalink
Ignore old value's path in copy_field Fix function. (#377)
Browse files Browse the repository at this point in the history
  • Loading branch information
blackwinter committed Oct 16, 2024
1 parent ea9fa70 commit 99361dd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
6 changes: 3 additions & 3 deletions metafix/src/main/java/org/metafacture/metafix/FixMethod.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public void apply(final Metafix metafix, final Record record, final List<String>

h.forEach((subField, value) -> {
record.addNested(field, new Value(subField));
record.addNested(field, value);
record.addNested(field, value.withPathSet(null));
});
})));
}
Expand Down Expand Up @@ -210,9 +210,9 @@ public void apply(final Metafix metafix, final Record record, final List<String>
oldValue.matchType()
.ifArray(a -> {
record.remove(newName);
a.forEach(v -> record.addNested(newName, v));
a.forEach(v -> record.addNested(newName, v.withPathSet(null)));
})
.orElse(v -> record.set(newName, v));
.orElse(v -> record.set(newName, v.withPathSet(null)));
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2188,10 +2188,9 @@ public void inDoBindCopyFieldWithVarInSourceAndTarget() {
);
}

@Test
public void replaceAllWithWildcardAfterCopyFieldWithVarInSourceAndTarget() {
private void replaceAllWithWildcardAfterCopyFieldWithVarInSourceAndTarget(final boolean explicitArray) {
MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList(
"set_array('RSWK[]')",
explicitArray ? "set_array('RSWK[]')" : "",
"do list(path: '650??', 'var': '$i')",
" copy_field('$i.a', 'RSWK[].$append.subjectTopicName')",
" copy_field('$i.v', 'RSWK[].$last.subjectGenre')",
Expand Down Expand Up @@ -2227,6 +2226,16 @@ public void replaceAllWithWildcardAfterCopyFieldWithVarInSourceAndTarget() {
);
}

@Test
public void replaceAllWithWildcardAfterCopyFieldWithVarInSourceAndTarget() {
replaceAllWithWildcardAfterCopyFieldWithVarInSourceAndTarget(true);
}

@Test
public void replaceAllWithWildcardAfterCopyFieldWithVarInSourceAndTargetImplicitArray() {
replaceAllWithWildcardAfterCopyFieldWithVarInSourceAndTarget(false);
}

@Test
public void multipleReplaceAllWithWildcardAfterCopyFieldWithVarInSourceAndTarget() {
MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList(
Expand Down

This file was deleted.

0 comments on commit 99361dd

Please sign in to comment.