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 2500fd6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 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 @@ -2190,8 +2190,17 @@ public void inDoBindCopyFieldWithVarInSourceAndTarget() {

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

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

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

This file was deleted.

0 comments on commit 2500fd6

Please sign in to comment.