File tree Expand file tree Collapse file tree 3 files changed +33
-2
lines changed
main/java/org/metafacture/metafix
test/java/org/metafacture/metafix Expand file tree Collapse file tree 3 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -298,7 +298,7 @@ private String[] tail(final String[] fields) {
298
298
return Arrays .copyOfRange (fields , 1 , fields .length );
299
299
}
300
300
301
- private enum ReservedField {
301
+ /*package- private*/ enum ReservedField {
302
302
$append , $first , $last ;
303
303
304
304
private static final Map <String , ReservedField > STRING_TO_ENUM = new HashMap <>();
Original file line number Diff line number Diff line change 17
17
package org .metafacture .metafix ;
18
18
19
19
import org .metafacture .commons .tries .SimpleRegexTrie ;
20
+ import org .metafacture .metafix .FixPath .ReservedField ;
20
21
21
22
import java .util .ArrayList ;
22
23
import java .util .Collection ;
@@ -208,7 +209,10 @@ public Value asList(final Consumer<Array> consumer) {
208
209
209
210
/*package-private*/ Value updatePathRename (final String newName ) {
210
211
if (path != null ) {
211
- path = newName .replaceAll ("\\ $[^.]+" , split (path )[0 ]);
212
+ final String basePath = split (path )[0 ];
213
+ for (final ReservedField rf : ReservedField .values ()) {
214
+ path = newName .replace (rf .name (), basePath );
215
+ }
212
216
}
213
217
return this ;
214
218
}
Original file line number Diff line number Diff line change @@ -2031,6 +2031,33 @@ public void shouldReplaceAllRegexesInListCopiedArraySubField() {
2031
2031
);
2032
2032
}
2033
2033
2034
+ @ Test
2035
+ public void shouldCopyBindVarWithDollarAfterLookup () {
2036
+ MetafixTestHelpers .assertFix (streamReceiver , Arrays .asList (
2037
+ "set_array('@coll[]')" ,
2038
+ "do list(path: 'a', 'var': '$i')" ,
2039
+ " lookup('$i.name')" ,
2040
+ " copy_field('$i.name', '@coll[].$append')" ,
2041
+ "end" ,
2042
+ "remove_field('a')"
2043
+ ),
2044
+ i -> {
2045
+ i .startRecord ("1" );
2046
+ i .startEntity ("a" );
2047
+ i .literal ("name" , "Dog" );
2048
+ i .endEntity ();
2049
+ i .endRecord ();
2050
+ },
2051
+ (o , f ) -> {
2052
+ o .get ().startRecord ("1" );
2053
+ o .get ().startEntity ("@coll[]" );
2054
+ o .get ().literal ("1" , "Dog" );
2055
+ f .apply (1 ).endEntity ();
2056
+ o .get ().endRecord ();
2057
+ }
2058
+ );
2059
+ }
2060
+
2034
2061
@ Test
2035
2062
// See https://github.com/metafacture/metafacture-fix/issues/121
2036
2063
public void shouldReplaceAllRegexesInNestedArray () {
You can’t perform that action at this time.
0 commit comments