YUKI Hiroshi
null+****@clear*****
Fri Nov 16 16:35:53 JST 2012
YUKI Hiroshi 2012-11-16 16:35:53 +0900 (Fri, 16 Nov 2012) New Revision: 8145a07621ad9e345d305ed7b5a92d99fe937f61 https://github.com/groonga/gcs/commit/8145a07621ad9e345d305ed7b5a92d99fe937f61 Log: Convert existing values to new index field type Modified files: lib/database/index-field.js Modified: lib/database/index-field.js (+32 -0) =================================================================== --- lib/database/index-field.js 2012-11-16 16:25:25 +0900 (1d2d8cc) +++ lib/database/index-field.js 2012-11-16 16:35:53 +0900 (608a10f) @@ -484,9 +484,41 @@ IndexField.prototype = { this.deleteSync(); this._type = type; this.createSync(true); + var name = this.columnName; + values.forEach(function(record) { + var value = record[name]; + switch (type) { + case 'text': + record[name] = Array.isArray(value) ? + value.map(this._toText, this) : this._toText(value); + break; + + case 'literal': + record[name] = Array.isArray(value) ? + value.map(this._toLiteral, this) : this._toLiteral(value); + break; + + case 'uint': + record[name] = Array.isArray(value) ? + value.map(this._toUInt, this) : this._toUInt(value); + break; + } + }); this.domain.loadSync(values); return this; }, + _toText: function(value) { + return value.toString(); + }, + _toLiteral: function(value) { + return value.toString(); + }, + _toUInt: function(value) { + value = parseInt(value); + if (isNaN(value)) + value = 0; + return value; + }, validateOptions: function() { if (this.facetEnabled && this.resultEnabled) -------------- next part -------------- HTML����������������������������... Télécharger