[Groonga-commit] groonga/gcs [master] Convert multiple values fields correctly

Back to archive index

YUKI Hiroshi null+****@clear*****
Mon Dec 10 17:46:19 JST 2012


YUKI Hiroshi	2012-12-10 17:46:19 +0900 (Mon, 10 Dec 2012)

  New Revision: dffe9b4b4eb6ed5199a35a3ffc478a354622cb3c
  https://github.com/groonga/gcs/commit/dffe9b4b4eb6ed5199a35a3ffc478a354622cb3c

  Log:
    Convert multiple values fields correctly

  Modified files:
    lib/batch/xml.js

  Modified: lib/batch/xml.js (+8 -1)
===================================================================
--- lib/batch/xml.js    2012-12-10 17:43:53 +0900 (d496805)
+++ lib/batch/xml.js    2012-12-10 17:46:19 +0900 (8c928a7)
@@ -39,9 +39,16 @@ function toJSON(xml) {
       if (!Array.isArray(fields)) fields = [fields];
 
       fields.forEach(function(field) {
+        var name = field['@'].name;
         var value = field['#'];
         if (UINT_MATCHER.test(value)) value = parseInt(value);
-        batch.fields[field['@'].name] = value;
+        if (name in batch.fields) {
+          if (!Array.isArray(batch.fields[name]))
+            batch.fields[name] = [batch.fields[name]];
+          batch.fields[name].push(value);
+        } else {
+          batch.fields[name] = value;
+        }
       });
 
       batches.push(batch);
-------------- next part --------------
HTML����������������������������...
Télécharger 



More information about the Groonga-commit mailing list
Back to archive index