[Groonga-commit] groonga/gcs [master] Update behaviour around index field options

Back to archive index

SHIMODA Hiroshi null+****@clear*****
Mon Aug 13 18:05:18 JST 2012


SHIMODA Hiroshi	2012-08-13 18:05:18 +0900 (Mon, 13 Aug 2012)

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

  Log:
    Update behaviour around index field options

  Modified files:
    lib/api/2011-02-01/configuration.js
    test/api-configuration.test.js

  Modified: lib/api/2011-02-01/configuration.js (+6 -4)
===================================================================
--- lib/api/2011-02-01/configuration.js    2012-08-13 18:00:25 +0900 (21badbb)
+++ lib/api/2011-02-01/configuration.js    2012-08-13 18:05:18 +0900 (c8daef9)
@@ -247,6 +247,9 @@ handlers.DefineIndexField = function(context, request, response) {
 
   var createdAt = new Date();
   try {
+    if (!field.exists())
+      field.type = fieldType;
+
     var facetEnabled = getFieldOption('FacetEnabled', request, fieldType);
     if (facetEnabled !== undefined)
       field.facetEnabled = facetEnabled.toLowerCase() == 'true';
@@ -259,12 +262,11 @@ handlers.DefineIndexField = function(context, request, response) {
     if (searchEnabled !== undefined)
       field.searchEnabled = searchEnabled.toLowerCase() == 'true';
 
-    if (!field.exists()) {
-      field.type = fieldType;
+    if (!field.exists())
       field.createSync();
-    } else {
+    else
       field.saveOptionsSync();
-    }
+
     response.contentType('application/xml');
     response.send(createDefineIndexFieldResponse({
       field: field,

  Modified: test/api-configuration.test.js (+5 -5)
===================================================================
--- test/api-configuration.test.js    2012-08-13 18:00:25 +0900 (16f9724)
+++ test/api-configuration.test.js    2012-08-13 18:05:18 +0900 (9bf2709)
@@ -433,7 +433,7 @@ suite('Configuration API', function() {
       .next(function(response) {
         var domain = new Domain('companies', context);
         var field = domain.getIndexField('name');
-        assert.isTrue(field.exists());
+        assert.isTrue(field.exists(), response.body);
 
         response = toParsedResponse(response);
         assert.deepEqual(response.pattern,
@@ -470,7 +470,7 @@ suite('Configuration API', function() {
       .next(function(response) {
         var domain = new Domain('companies', context);
         var field = domain.getIndexField('name');
-        assert.isTrue(field.exists());
+        assert.isTrue(field.exists(), response.body);
 
         response = toParsedResponse(response);
         assert.deepEqual(response.pattern,
@@ -506,7 +506,7 @@ suite('Configuration API', function() {
       .next(function(response) {
         var domain = new Domain('companies', context);
         var field = domain.getIndexField('age');
-        assert.isTrue(field.exists());
+        assert.isTrue(field.exists(), response.body);
 
         response = toParsedResponse(response);
         assert.deepEqual(response.pattern,
@@ -540,7 +540,7 @@ suite('Configuration API', function() {
       .next(function(response) {
         var domain = new Domain('companies', context);
         var field = domain.getIndexField('product');
-        assert.isTrue(field.exists());
+        assert.isTrue(field.exists(), response.body);
 
         response = toParsedResponse(response);
         assert.deepEqual(response.pattern,
@@ -580,7 +580,7 @@ suite('Configuration API', function() {
       .next(function(response) {
         var domain = new Domain('companies', context);
         var field = domain.getIndexField('product');
-        assert.isTrue(field.exists());
+        assert.isTrue(field.exists(), response.body);
 
         response = toParsedResponse(response);
         assert.deepEqual(response.pattern,
-------------- next part --------------
HTML����������������������������...
Download 



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