Browse Source

[3360] Fix dbaccess parser to use "persist" value as boolean.

Marcin Siodelski 11 years ago
parent
commit
8b5ded2f87

+ 9 - 1
src/lib/dhcpsrv/dbaccess_parser.cc

@@ -58,7 +58,15 @@ DbAccessParser::build(isc::data::ConstElementPtr config_value) {
 
     // 3. Update the copy with the passed keywords.
     BOOST_FOREACH(ConfigPair param, config_value->mapValue()) {
-        values_copy[param.first] = param.second->stringValue();
+        // The persist parameter is the only boolean parameter at the
+        // moment. It needs special handling.
+        if (param.first != "persist") {
+            values_copy[param.first] = param.second->stringValue();
+
+        } else {
+            values_copy[param.first] = (param.second->boolValue() ?
+                                        "true" : "false");
+        }
     }
 
     // 4. Perform validation checks on the updated set of keyword/values.

+ 8 - 2
src/lib/dhcpsrv/tests/dbaccess_parser_unittest.cc

@@ -87,8 +87,14 @@ public:
             }
 
             // Add the keyword and value - make sure that they are quoted.
-            result += quote + keyval[i] + quote + colon + space +
-                      quote + keyval[i + 1] + quote;
+            // The only parameter which is not quoted is persist as it
+            // is a boolean value.
+            result += quote + keyval[i] + quote + colon + space;
+            if (keyval[i] != "persist") {
+                result += quote + keyval[i + 1] + quote;
+            } else {
+                result += keyval[i + 1];
+            }
         }
 
         // Add the terminating brace