rapidpro / expressions

Expression parsing and evaluation support
BSD 3-Clause "New" or "Revised" License
4 stars 4 forks source link

Add function that always return an empty string so it can be used to clear field values #33

Closed norkans7 closed 5 years ago

rowanseymour commented 5 years ago

The problem isn't the expression engine, it's the old editor. In the engine it's perfectly valid to set a field value to empty string. It's the old editor which doesn't accept that input being empty so we've ended up telling people to use @("").

The new editor addresses this and I think we just keep using the @("") workaround until then - which the legacy->new flow migration will replace with empty string.

nicpottier commented 5 years ago

Do we actually detect @("") as a special case expression and replace with "" in new flows? (not saying at evaluation time, saying in the definition itself?

rowanseymour commented 5 years ago

it's at flow migration time https://github.com/nyaruka/goflow/blob/master/legacy/expressions/migrate.go#L73

so a set_contact_field action that was "value": "@(\"\")" becomes "value": ""

nicpottier commented 5 years ago

noice!