[Groonga-commit] groonga/gcs [master] Validate index field only its name on deletion

アーカイブの一覧に戻る

YUKI Hiroshi null+****@clear*****
Wed Nov 21 18:53:04 JST 2012


YUKI Hiroshi	2012-11-21 18:53:04 +0900 (Wed, 21 Nov 2012)

  New Revision: 892f7497aab0022ee9d4f1fbd3481807fce99f3f
  https://github.com/groonga/gcs/commit/892f7497aab0022ee9d4f1fbd3481807fce99f3f

  Log:
    Validate index field only its name on deletion

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

  Modified: lib/api/2011-02-01/configuration.js (+2 -2)
===================================================================
--- lib/api/2011-02-01/configuration.js    2012-11-21 18:40:27 +0900 (d1aa3a3)
+++ lib/api/2011-02-01/configuration.js    2012-11-21 18:53:04 +0900 (ea07021)
@@ -369,7 +369,7 @@ handlers.DeleteIndexField = function(context, request, response, config) {
 
   var fieldName = request.query['IndexFieldName'] || '';
   var field = handleIndexFieldValidationError(function() {
-        return domain.getIndexField(fieldName).validate();
+        return domain.getIndexField(fieldName).validateName();
       }, {
         NAME_FIELD: 'indexFieldName'
       });
@@ -609,7 +609,7 @@ exports.createHandler = function(context, config) {
             break;
         }
       } else {
-        body= createCommonErrorResponse('InternalFailure', error.stack || error, request.id);
+        body = createCommonErrorResponse('InternalFailure', error.stack || error, request.id);
         code = 500;
       }
       response.contentType('application/xml');

  Modified: lib/database/index-field.js (+15 -0)
===================================================================
--- lib/database/index-field.js    2012-11-21 18:40:27 +0900 (e4162db)
+++ lib/database/index-field.js    2012-11-21 18:53:04 +0900 (c36504b)
@@ -147,6 +147,21 @@ IndexField.prototype = {
     return this;
   },
 
+  validateName: function() {
+    if (typeof this.name != 'string')
+      throw new ValidationError('field name must be a string');
+
+    var errors = collectNameValidationErrors(this.name);
+    if (errors.length) {
+      var prefix = errors.length > 1 ? 
+                     errors.length + ' validation errors detected: ' :
+                     '1 validation error detected: ';
+      throw new ValidationError(prefix + errors.join('; '));
+    }
+
+    return this;
+  },
+
   get columnName() {
     if (!this._columnName)
       this._columnName = IndexField.toColumnNamePart(this.name);
-------------- next part --------------
HTML����������������������������...
ダウンロード 



More information about the Groonga-commit mailing list
アーカイブの一覧に戻る