[Groonga-commit] groonga/gcs [master] Raise error for index field creation by DefineIndexField without field type

Back to archive index

YUKI Hiroshi null+****@clear*****
Thu Nov 15 18:01:56 JST 2012


YUKI Hiroshi	2012-11-15 18:01:56 +0900 (Thu, 15 Nov 2012)

  New Revision: 0162fa81f9c01a8c7e9edd3faf3527cd8dee4f0c
  https://github.com/groonga/gcs/commit/0162fa81f9c01a8c7e9edd3faf3527cd8dee4f0c

  Log:
    Raise error for index field creation by  DefineIndexField without field 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 17:55:46 +0900 (7f4ab2c)
+++ lib/api/2011-02-01/configuration.js    2012-11-15 18:01:56 +0900 (cde5719)
@@ -296,7 +296,7 @@ handlers.DefineIndexField = function(context, request, response, config) {
 
   var createdAt = new Date();
   var fieldName = request.query['IndexField.IndexFieldName'] || '';
-  var fieldType = request.query['IndexField.IndexFieldType'] || 'text';
+  var fieldType = request.query['IndexField.IndexFieldType'] || '';
   var field = handleIndexFieldValidationError(function() {
         var field = domain.getIndexField(fieldName);
         if (!field.exists())

  Modified: lib/database/index-field.js (+8 -9)
===================================================================
--- lib/database/index-field.js    2012-11-15 17:55:46 +0900 (da0509a)
+++ lib/database/index-field.js    2012-11-15 18:01:56 +0900 (5e5f8c3)
@@ -88,19 +88,18 @@ function assertValidFieldName(field) {
 }
 
 function assertValidFieldType(type) {
-  if (typeof type != 'string') {
-    var error = new Error('field type must be a string');
-    error.isValidationError = true;
-    throw error;
-  }
-
   var errors = [];
   var commonPrefix = 'Value \'' + type + '\' at \'%TYPE_FIELD%\' failed ' +
                      'to satisfy constraint: ';
 
-  if (VALID_FIELD_TYPES.indexOf(type) < 0)
-    errors.push(commonPrefix + 'Member must satisfy enum value set: [' +
-                  VALID_FIELD_TYPES.join(', ') + ']');
+  if (!type) {
+    errors.push('Value null at \'%TYPE_FIELD%\' failed to satisfy ' +
+                  'constraint: Member must not be null');
+  } else {
+    if (VALID_FIELD_TYPES.indexOf(type) < 0)
+      errors.push(commonPrefix + 'Member must satisfy enum value set: [' +
+                    VALID_FIELD_TYPES.join(', ') + ']');
+  }
 
   if (errors.length) {
     var prefix = errors.length > 1 ? 
-------------- next part --------------
HTML����������������������������...
Télécharger 



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