@guessed : yes for sure this is a change in the behaviour of the Map. Iirw, I did it provide a better function by default (e.g.when used in sitemaps). At this point I’m not really clear on what should be the reaction of a faultly transformation null or original value…
I can certainly see examples of wanting to change the behavior of existing transforms (REGEX confuses a lot of people, for example) but without a mechanism to provide options (for compatibility etc) I don’t think we should change the behavior.
In the case of MAP, it’s easy to see that either null/empty or original string are reasonable return options when there’s no match, but I’d always vote for compatibility in these cases… Esp when there’s no obvious error in the usage.
If we want different behavior, then I’d vote that we create MAP2 (etc) with that new behavior. This would avoid users seeing behavioral changes when they’re upgrading one release to the next.
@guessed, @Kai : from what I see in the MapTransformationServiceTest here , the current behaviour of the Map service is as expected by the test designed by Kai (lines 72/76).
Do we all agree that I change that to return empty string when not found ?
Here’s my simple OH 1.x MAP Test Rule, and it’s output under 1.8.1 showing the Empty string result:
rule "Test MAP behavior"
Time cron "0/10 * * * * ?"
var closed = transform("MAP", "en.map", "CLOSED")
var other = transform("MAP", "en.map", "OTHER")
logInfo("test-MAP", String::format("CLOSED='%1$s' OTHER='%2$s'", closed, other))
08:12:40.004 DEBUG o.o.m.r.i.e.ExecuteRuleJob[:53]- Executing scheduled rule 'Test MAP behavior'
08:12:40.008 WARN o.o.c.t.i.s.MapTransformationService[:67]- Could not find a mapping for 'OTHER' in the file 'en.map'.
08:12:40.012 INFO o.o.model.script.test-MAP[:53]- CLOSED='closed' OTHER=''