null+****@clear*****
null+****@clear*****
2012年 7月 11日 (水) 19:17:15 JST
SHIMODA Hiroshi 2012-07-11 19:17:15 +0900 (Wed, 11 Jul 2012) New Revision: 08391c59cf96b3948b27e323e3ee8d75efb12c0a https://github.com/groonga/gcs/commit/08391c59cf96b3948b27e323e3ee8d75efb12c0a Log: Return actual IndexField instances by Domain#getIndexFieldsSync Modified files: lib/domain.js test/batch-processor.test.js Modified: lib/domain.js (+5 -6) =================================================================== --- lib/domain.js 2012-07-11 19:14:15 +0900 (91fd12f) +++ lib/domain.js 2012-07-11 19:17:15 +0900 (7cdb9c1) @@ -85,6 +85,7 @@ Domain.prototype = { // database and currently the column name is luckly equals to the // given field name, we can use the column name. var name = column.name; + var field = this.getIndexField(name); var type; if (column.type == 'var') { @@ -93,17 +94,14 @@ Domain.prototype = { } else if (column.type == 'fix') { if (column.range == Database.UInt32) type = 'uint'; - else if (column.range == this.getIndexField(name).alterTableName) + else if (column.range == field.alterTableName) type = 'literal'; } if (!type) throw new Error('unknown unfixed column '+column.name); - return { - name: name, - columnName: column.name, - type: type - }; + field.type = type; + return field; }, get synonymTableName() { if (!this._synonymTableName) @@ -167,6 +165,7 @@ function assertValidFieldName(field) { function IndexField(name, domain) { this.domain = domain; this.name = name; + this.type = null; this.initialize(); }; IndexField.prototype = { Modified: test/batch-processor.test.js (+6 -6) =================================================================== --- test/batch-processor.test.js 2012-07-11 19:14:15 +0900 (2f0f82d) +++ test/batch-processor.test.js 2012-07-11 19:17:15 +0900 (15af720) @@ -48,24 +48,24 @@ suite('batch/processor/Processor (instance methods)', function() { test('getIndexFields', function() { var fields = processor.getIndexFields(); + fields = fields.map(function(field) { + return { + name: field.name, + type: field.name + }; + }); var expected = [ { name: 'address', - columnName: 'address', type: 'text'}, { name: 'age', - columnName: 'age', type: 'uint'}, { name: 'description', - columnName: 'description', type: 'text'}, { name: 'email_address', - columnName: 'email_address', type: 'text'}, { name: 'name', - columnName: 'name', type: 'text'}, { name: 'product', - columnName: 'product', type: 'literal'} ]; function sortFields(a, b) { -------------- next part -------------- HTML$B$NE:IU%U%!%$%k$rJ]4I$7$^$7$?(B... 下载