-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lookup option default does not work #333
Comments
The default key uses two underscores ( put_map("typeMap",
"dog": "mammal",
"parrot": "bird",
"shark": "fish",
__default: "other"
) |
okay, then this behaviour is different to catmandu:
|
and the documentation is incorrect: https://github.com/metafacture/metafacture-fix#lookup |
The name difference is a Metamorph relict, the behaviour should be adapted IMO (would be a behaviour change, though). diff --git metafix/src/main/java/org/metafacture/metafix/FixMethod.java metafix/src/main/java/org/metafacture/metafix/FixMethod.java
index 0b185ca..56de7e9 100644
--- metafix/src/main/java/org/metafacture/metafix/FixMethod.java
+++ metafix/src/main/java/org/metafacture/metafix/FixMethod.java
@@ -516,7 +516,7 @@ public enum FixMethod implements FixFunction { // checkstyle-disable-line ClassD
map = metafix.getMap(mapName);
}
- final String defaultValue = map.get(Maps.DEFAULT_MAP_KEY); // TODO: Catmandu uses 'default'
+ final String defaultValue = options.getOrDefault(Maps.DEFAULT_MAP_KEY, map.get(Maps.DEFAULT_MAP_KEY)); // TODO: Catmandu uses 'default'
final boolean delete = getBoolean(options, "delete");
final boolean printUnknown = getBoolean(options, "print_unknown"); |
See example here:
https://metafacture.org/playground/?flux=inputFile%0A%7C+open-file%0A%7C+as-records%0A%7C+decode-yaml%0A%7C+fix%28transformationFile%29%0A%7C+encode-yaml%0A%7C+print%0A%3B%0A&transformation=put_map%28%22typeMap%22%2C%0A++%22dog%22%3A+%22mammal%22%2C%0A++%22parrot%22%3A+%22bird%22%2C%0A++%22shark%22%3A+%22fish%22%0A%29%0A%0Acopy_field%28%22animal%22%2C%22type%22%29%0A%0Alookup%28%22type%22%2C%22typeMap%22%2C+_default%3A%22other%22%29%0A&data=---%0Aanimal%3A+dog%0A%0A---%0Aanimal%3A+parrot%0A%0A%0A---%0Aanimal%3A+shark%0A%0A---%0Aanimal%3A+crab
The text was updated successfully, but these errors were encountered: