فهرست منبع

implement conversion from empty string to null

utsushiiro 7 سال پیش
والد
کامیت
04c701850d
1فایلهای تغییر یافته به همراه13 افزوده شده و 1 حذف شده
  1. 13 1
      src/server/service/config-loader.js

+ 13 - 1
src/server/service/config-loader.js

@@ -209,7 +209,19 @@ class ConfigLoader {
       if (!config[doc.ns]) {
         config[doc.ns] = {};
       }
-      config[doc.ns][doc.key] = JSON.parse(doc.value);
+
+      let value = JSON.parse(doc.value);
+
+      /*
+       * In the new API, only null is used as a value to indicate that a config is not set.
+       * In the old API, however, an empty character string is also used for the same purpose.
+       * So, a empty string is converted to null to ensure compatibility.
+       */
+      if (value === '') {
+        value = null;
+      }
+
+      config[doc.ns][doc.key] = value;
     }
 
     debug('ConfigLoader#loadFromDB', config);