From d0fd3bac4adda44d1fc7e30329cf4fc72ca098c8 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 14 Sep 2014 16:36:32 -0400 Subject: [PATCH] TDB2 - ::update must call validate(false) to ensure metadata exists for the 'modify' case, then later call validate() to add defaults for the 'add' case. --- src/TDB2.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/TDB2.cpp b/src/TDB2.cpp index d60ad3bc9..4340b35f4 100644 --- a/src/TDB2.cpp +++ b/src/TDB2.cpp @@ -604,6 +604,9 @@ void TDB2::update ( std::vector ::iterator 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. Task original; if (get (i->get ("uuid"), original)) @@ -623,6 +626,9 @@ void TDB2::update ( } else { + // Re-validate to add default values. + i->validate (); + // Add new task to either pending or completed. std::string status = i->get ("status"); if (status == "completed" ||