YUKI Hiroshi
null+****@clear*****
Wed Nov 21 19:00:15 JST 2012
YUKI Hiroshi 2012-11-21 19:00:15 +0900 (Wed, 21 Nov 2012) New Revision: c1351061eb43cb41bf65655a53e21d88002af105 https://github.com/groonga/gcs/commit/c1351061eb43cb41bf65655a53e21d88002af105 Log: Ignore unknown field options Modified files: lib/api/2011-02-01/configuration.js Modified: lib/api/2011-02-01/configuration.js (+17 -19) =================================================================== --- lib/api/2011-02-01/configuration.js 2012-11-21 18:53:04 +0900 (ea07021) +++ lib/api/2011-02-01/configuration.js 2012-11-21 19:00:15 +0900 (cf5e6f1) @@ -299,27 +299,27 @@ var UINT_FIELD_OPTIONS = IndexField.UINT_FIELD_OPTIONS.map(function(option) { return 'IndexField.UIntOptions.' + option; }); -function assertValidFieldOptions(request, type, domainName) { +function getFieldOption(option, request, type) { + var optionName; + switch (type) { + case 'text': + optionName = 'IndexField.TextOptions.' + option; + break; + case 'literal': + optionName = 'IndexField.LiteralOptions.' + option; + break; + case 'uint': + optionName = 'IndexField.UIntOptions.' + option; + break; + } + var validOptions = type == 'text' ? TEXT_FIELD_OPTIONS : type == 'literal' ? LITERAL_FIELD_OPTIONS : UINT_FIELD_OPTIONS; - - var options = Object.keys(request.query).filter(function(name) { - return /^IndexField\.[^\.]+Options\./.test(name); - }); - if (options.some(function(name) { - return validOptions.indexOf(name) < 0; - })) - throw new errors.ResourceNotFoundError('Domain not found: ' + domainName); -} + if (validOptions.indexOf(optionName) < 0) + return undefined; -function getFieldOption(option, request, type) { - if (type == 'text') - return request.query['IndexField.TextOptions.' + option]; - if (type == 'literal') - return request.query['IndexField.LiteralOptions.' + option]; - else - return request.query['IndexField.UIntOptions.' + option]; + return request.query[optionName]; } handlers.DefineIndexField = function(context, request, response, config) { @@ -336,8 +336,6 @@ handlers.DefineIndexField = function(context, request, response, config) { return domain.getIndexField(fieldName).setType(fieldType).validate(); }); - assertValidFieldOptions(request, fieldType, domainName); - var facetEnabled = getFieldOption('FacetEnabled', request, fieldType); if (facetEnabled !== undefined) field.facetEnabled = facetEnabled.toLowerCase() == 'true'; -------------- next part -------------- HTML����������������������������... 다운로드