Skip to content

Commit

Permalink
Merge pull request #380 from metafacture/377-ignoreOldValuePath
Browse files Browse the repository at this point in the history
Ignore old value's path in `copy_field` Fix function.
  • Loading branch information
blackwinter authored Nov 29, 2024
2 parents d9b25ec + 99361dd commit 22b6824
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 @@ -197,7 +197,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 @@ -227,9 +227,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,10 +2190,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 @@ -2229,6 +2228,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 22b6824

Please sign in to comment.