[Groonga-commit] droonga/express-droonga at 35e4510 [master] Support comma-separated string as a value of attributes for sub records

Back to archive index

YUKI Hiroshi null+****@clear*****
Wed May 28 12:54:40 JST 2014


YUKI Hiroshi	2014-05-28 12:54:40 +0900 (Wed, 28 May 2014)

  New Revision: 35e4510f938c1ad99de57d4bddeb780557be2f7f
  https://github.com/droonga/express-droonga/commit/35e4510f938c1ad99de57d4bddeb780557be2f7f

  Message:
    Support comma-separated string as a value of attributes for sub records

  Modified files:
    lib/adapter/api/rest-request-builder.js
    test/rest-request-builder.test.js

  Modified: lib/adapter/api/rest-request-builder.js (+4 -1)
===================================================================
--- lib/adapter/api/rest-request-builder.js    2014-05-28 12:44:33 +0900 (5b1c67d)
+++ lib/adapter/api/rest-request-builder.js    2014-05-28 12:54:40 +0900 (9841562)
@@ -138,8 +138,11 @@ function buildGroupByQuery(sourceQueryName, params) {
           label: key
         };
         attribute.source = requestAttribute.source;
-        if ('attributes' in requestAttribute)
+        if ('attributes' in requestAttribute) {
           attribute.attributes = requestAttribute.attributes;
+          if (typeof attribute.attributes == 'string')
+            attribute.attributes = attribute.attributes.split(/\s*,\s*/);
+        }
         attributes.push(attribute);
       });
     }

  Modified: test/rest-request-builder.test.js (+24 -0)
===================================================================
--- test/rest-request-builder.test.js    2014-05-28 12:44:33 +0900 (a18049c)
+++ test/rest-request-builder.test.js    2014-05-28 12:54:40 +0900 (22eb695)
@@ -331,6 +331,30 @@ suite('building message from REST adapter request', function() {
                            expected);
         });
 
+        test('attributes with comma separated attributes', function() {
+          var query = {
+            key: '_key',
+            attributes: {
+              sub_records: {
+                source: '_subrecs',
+                attributes: 'title,name'
+              }
+            }
+          };
+          var expected = [
+            {
+              label: 'sub_records',
+              source: '_subrecs',
+              attributes: [
+                'title',
+                'name'
+              ]
+            }
+          ];
+          assert.equalJSON(buildGroupByQuery(query).output.attributes,
+                           expected);
+        });
+
         test('attributes', function() {
           var query = {
             key: '_key',
-------------- next part --------------
HTML����������������������������...
下載 



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