[Groonga-commit] groonga/gcs [master] Accept updating of index field with different type

Back to archive index

YUKI Hiroshi null+****@clear*****
Thu Nov 15 19:13:30 JST 2012


YUKI Hiroshi	2012-11-15 19:13:30 +0900 (Thu, 15 Nov 2012)

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

  Log:
    Accept updating of index field with different type

  Modified files:
    lib/api/2011-02-01/configuration.js
    lib/database/index-field.js

  Modified: lib/api/2011-02-01/configuration.js (+1 -1)
===================================================================
--- lib/api/2011-02-01/configuration.js    2012-11-15 19:10:19 +0900 (6d84646)
+++ lib/api/2011-02-01/configuration.js    2012-11-15 19:13:30 +0900 (8cd276b)
@@ -303,7 +303,7 @@ handlers.DefineIndexField = function(context, request, response, config) {
   var fieldType = request.query['IndexField.IndexFieldType'] || '';
   var field = handleIndexFieldValidationError(function() {
         var field = domain.getIndexField(fieldName);
-        if (!field.exists())
+        if (!field.exists() || fieldType)
           field.type = fieldType;
         return field;
       });

  Modified: lib/database/index-field.js (+12 -1)
===================================================================
--- lib/database/index-field.js    2012-11-15 19:10:19 +0900 (b0bdc00)
+++ lib/database/index-field.js    2012-11-15 19:13:30 +0900 (8f9b2b6)
@@ -204,7 +204,10 @@ IndexField.prototype = {
   },
   set type(type) {
     assertValidFieldType(type);
-    return this._type = type
+    this._type = type;
+    if (this.exists())
+      this.changeTypeSync();
+    return type;
   },
   setType: function(type) {
     this.type = type;
@@ -473,6 +476,14 @@ IndexField.prototype = {
     return this;
   },
 
+  changeTypeSync: function() {
+    var values = this.domain.dumpSync();
+    this.deleteSync();
+    this.createSync(true);
+    this.domain.loadSync(values);
+    return this;
+  },
+
   validateOptions: function() {
     if (this.facetEnabled && this.resultEnabled)
       throw new FieldTypeValidationError(
-------------- next part --------------
HTML����������������������������...
Download 



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