-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from nextstrain/update-transform-field-names
`transform-field-names`: Skip field if `old_field_name` == `new_field_name`
- Loading branch information
Showing
2 changed files
with
33 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
Verify behavior of `transform-field-names` | ||
|
||
If the `--field-map` includes a old field name that is the same as the new field | ||
name, this should be no-op. | ||
|
||
$ echo '{"strain": "A"}' \ | ||
> | $TESTDIR/../../transform-field-names \ | ||
> --field-map "strain=strain" | ||
{"strain":"A"} | ||
|
||
If the `--field-map` overwrites an existing field, then skip renaming and | ||
print a loud warning. | ||
|
||
$ echo '{"strain": "A", "isolate": "B"}' \ | ||
> | $TESTDIR/../../transform-field-names \ | ||
> --field-map "isolate=strain" | ||
WARNING: skipping rename of isolate because record already has a field named strain. | ||
{"strain":"A","isolate":"B"} | ||
|
||
The `--field-map` may overwrite an existing field if using `--force` flag. | ||
|
||
$ echo '{"strain": "A", "isolate": "B"}' \ | ||
> | $TESTDIR/../../transform-field-names \ | ||
> --field-map "isolate=strain" \ | ||
> --force | ||
{"strain":"B"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters