Remove properties when set to an empty string

Fixes #3109.
This commit is contained in:
Dustin J. Mitchell 2023-05-28 21:13:01 +00:00 committed by Dustin J. Mitchell
parent 6cd5bf1237
commit a69b0c8032
2 changed files with 17 additions and 1 deletions

View file

@ -169,7 +169,12 @@ void TDB2::modify (Task& task)
update = true; update = true;
} }
if (update) { if (update) {
tctask.set_value(k, make_optional (v_new)); // An empty string indicates the value should be removed.
if (v_new == "") {
tctask.set_value(k, {});
} else {
tctask.set_value(k, make_optional (v_new));
}
} }
} }

11
test/tw-3109.t Normal file
View file

@ -0,0 +1,11 @@
#!/usr/bin/env bash
. bash_tap_tw.sh
task add emptyval
task 1 done
task 1 mod end: status:pending
task_end=`task 1 info | grep ^End | sed -e 's/^End //' || true`
echo "task_end: $task_end"
# `task mod end:` should have deleted the end.
[[ "$task_end" == "" ]]