YUKI Hiroshi
null+****@clear*****
Mon Nov 19 13:58:29 JST 2012
YUKI Hiroshi 2012-11-19 13:58:29 +0900 (Mon, 19 Nov 2012) New Revision: 4b39de16f71c46e9f243aa9a8a9151aac0c08a05 https://github.com/groonga/gcs/commit/4b39de16f71c46e9f243aa9a8a9151aac0c08a05 Log: Save updateVersion of index fields Modified files: lib/api/2011-02-01/configuration.js lib/database/index-field.js Modified: lib/api/2011-02-01/configuration.js (+6 -7) =================================================================== --- lib/api/2011-02-01/configuration.js 2012-11-16 19:09:11 +0900 (da157f9) +++ lib/api/2011-02-01/configuration.js 2012-11-19 13:58:29 +0900 (45dd743) @@ -258,7 +258,7 @@ function createOptionStatus(options) { var optionStatus = xmlbuilder.create(); var createdAt = options.field ? options.field.createdAt : options.createdAt; var updatedAt = options.field ? options.field.updatedAt : options.updatedAt; - var updateVersion = /* options.field ? options.field.updateVersion : */ options.updateVersion; + var updateVersion = options.field ? options.field.updateVersion : options.updateVersion; var state = options.field ? options.field.state : options.state; optionStatus.begin(options.element || 'Status', { version: '1.0' }) .element('CreationDate').text(dateFormat(createdAt, 'isoUtcDateTime')).up() @@ -276,9 +276,8 @@ function createIndexFieldStatus(options) { .element('IndexFieldType').text(options.field.type).up() .importXMLBuilder(createIndexFieldOptionStatus(options.field)) .up() - .importXMLBuilder(createOptionStatus({ field: options.field, - updateVersion: options.updateVersion, - element: 'Status' })); + .importXMLBuilder(createOptionStatus({ field: options.field, + element: 'Status' })); return indexFieldStatus; } @@ -451,8 +450,8 @@ function createSynonymOptionsStatus(options) { .element('Options') .text(JSON.stringify(synonymOptions)) .up() - .importXMLBuilder(createOptionStatus({ createdAt: options.createdAt, - state: options.state, + .importXMLBuilder(createOptionStatus({ state: options.state, + createdAt: options.createdAt, updatedAt: options.updatedAt, updateVersion: options.updateVersion, element: 'Status' })); @@ -490,8 +489,8 @@ function createDefaultSearchFieldStatus(options) { defaultSearchFieldStatus.begin('DefaultSearchField', { version: '1.0' }) .element('Options').text(options.fieldName).up() .importXMLBuilder(createOptionStatus({ - createdAt: options.createdAt, state: options.state, + createdAt: options.createdAt, updatedAt: options.updatedAt, updateVersion: options.updateVersion, element: 'Status' Modified: lib/database/index-field.js (+25 -3) =================================================================== --- lib/database/index-field.js 2012-11-16 19:09:11 +0900 (ea82182) +++ lib/database/index-field.js 2012-11-19 13:58:29 +0900 (f4f98ed) @@ -389,6 +389,21 @@ IndexField.prototype = { return 'column_' + this.name + '_updated_at'; }, + get updateVersion() { + if (this.exists() && !this._updateVersion) + this._updateVersion = new Date(this.domain.getConfiguration(this.updateVersionKey)); + return this._updateVersion || new Date(); + }, + set updateVersion(value) { + if (this.exists()) + this.domain.setConfiguration(this.updateVersionKey, value.getTime()) + this._updateVersion = value; + return value; + }, + get updateVersionKey() { + return 'column_' + this.name + '_updateVersion'; + }, + get multipleValues() { return !!this.column && this.column.flags.indexOf(nroonga.COLUMN_VECTOR) > -1; @@ -428,9 +443,13 @@ IndexField.prototype = { this.saveOptionsSync(); var now = new Date(); - if (!this._createdAt) - this.createdAt = now; - this.updatedAt = now; + if (!this._createdAt) { + this.updatedAt = this.createdAt = now; + this.updateVersion = 1; + } else { + this.updatedAt = now; + this.updateVersion++; + } return this; }, @@ -458,6 +477,7 @@ IndexField.prototype = { } this.updatedAt = new Date(); + this.updateVersion++; return this; }, @@ -470,6 +490,7 @@ IndexField.prototype = { this._defaultSearchField = this.defaultSearchField; this._createdAt = this.createdAt; this._updatedAt = this.updatedAt; + this._updateVersion = this.updateVersion; if (this._type == 'uint' || this._type == 'literal') { this.context.commandSync('table_remove', { @@ -486,6 +507,7 @@ IndexField.prototype = { this.domain.deleteConfiguration(this.searchEnabledConfigurationKey); this.domain.deleteConfiguration(this.createdAtKey); this.domain.deleteConfiguration(this.updatedAtKey); + this.domain.deleteConfiguration(this.updateVersion); if (this._defaultSearchField) this.domain.defaultSearchField = null; -------------- next part -------------- HTML����������������������������...Télécharger