- ::update must call validate(false) to ensure metadata exists for the 'modify'
  case, then later call validate() to add defaults for the 'add' case.
This commit is contained in:
Paul Beckingham 2014-09-14 16:36:32 -04:00
parent 90edba9113
commit d0fd3bac4a

View file

@ -604,6 +604,9 @@ void TDB2::update (
std::vector <Task>::iterator i; std::vector <Task>::iterator i;
for (i = changes.begin (); i != changes.end (); ++i) for (i = changes.begin (); i != changes.end (); ++i)
{ {
// Validate to add metadata.
i->validate (false);
// If the task already exists, it is a modification, else addition. // If the task already exists, it is a modification, else addition.
Task original; Task original;
if (get (i->get ("uuid"), original)) if (get (i->get ("uuid"), original))
@ -623,6 +626,9 @@ void TDB2::update (
} }
else else
{ {
// Re-validate to add default values.
i->validate ();
// Add new task to either pending or completed. // Add new task to either pending or completed.
std::string status = i->get ("status"); std::string status = i->get ("status");
if (status == "completed" || if (status == "completed" ||