[Groonga-commit] groonga/gcs [master] Replace Field#fieldTypeToAlterTableKeyType to Field#alterTableKeyType

Back to archive index

null+****@clear***** null+****@clear*****
2012年 7月 12日 (木) 19:09:28 JST


SHIMODA Hiroshi	2012-07-12 19:09:28 +0900 (Thu, 12 Jul 2012)

  New Revision: 01a28cc52e2c85b4599661064f600cbfd9734ecf
  https://github.com/groonga/gcs/commit/01a28cc52e2c85b4599661064f600cbfd9734ecf

  Log:
    Replace Field#fieldTypeToAlterTableKeyType to Field#alterTableKeyType

  Modified files:
    lib/database/domain.js
    lib/database/index-field.js

  Modified: lib/database/domain.js (+1 -1)
===================================================================
--- lib/database/domain.js    2012-07-12 19:02:13 +0900 (926f57a)
+++ lib/database/domain.js    2012-07-12 19:09:28 +0900 (9eaab16)
@@ -160,7 +160,7 @@ Domain.prototype = {
         this.context.commandSync('table_create', {
           name: field.alterTableName,
           flags: nroonga.TABLE_HASH_KEY,
-          key_type: field.fieldTypeToAlterTableKeyType(fieldType)
+          key_type: field.alterTableKeyType
         });
         this.context.commandSync('column_create', {
           table: field.alterTableName,

  Modified: lib/database/index-field.js (+16 -15)
===================================================================
--- lib/database/index-field.js    2012-07-12 19:02:13 +0900 (3fc8796)
+++ lib/database/index-field.js    2012-07-12 19:09:28 +0900 (6e13a25)
@@ -70,6 +70,18 @@ IndexField.prototype = {
       this._alterTableName = this.domain.tableName + '_' + this.columnName;
     return this._alterTableName;
   },
+  get alterTableKeyType() {
+    var type = this.type;
+    switch (type) {
+      case 'uint':
+        return nroonga.UInt32;
+      case 'literal':
+        return nroonga.ShortText;
+      default:
+        throw new Error('Unsupported index field type '+type+
+                        ' for alter table');
+    }
+  },
   fieldTypeToColumnType: function(fieldType) {
     switch (fieldType) {
       case 'text':
@@ -94,17 +106,6 @@ IndexField.prototype = {
         throw new Error('Unsupported column type '+columnType);
     }
   },
-  fieldTypeToAlterTableKeyType: function(fieldType) {
-    switch (fieldType) {
-      case 'uint':
-        return nroonga.UInt32;
-      case 'literal':
-        return nroonga.ShortText;
-      default:
-        throw new Error('Unsupported index field type '+fieldType+
-                        ' for alter table');
-    }
-  },
 
   get column() {
     var columns = this.context.ordinalColumnsSync(this.domain.tableName);
@@ -125,12 +126,12 @@ IndexField.prototype = {
 
     if (column.type == 'var') {
       if (column.range == nroonga.ShortText)
-        return 'text';
+        return this._type = 'text';
     } else if (column.type == 'fix') {
       if (column.range == nroonga.UInt32)
-        return 'uint';
+        return this._type = 'uint';
       else if (column.range == this.alterTableName)
-        return 'literal';
+        return this._type = 'literal';
     }
 
     throw new Error('unknown unfixed column '+this.columnName);
@@ -149,7 +150,7 @@ IndexField.prototype = {
       this.context.commandSync('table_create', {
         name: this.alterTableName,
         flags: nroonga.TABLE_HASH_KEY,
-        key_type: this.fieldTypeToAlterTableKeyType(type)
+        key_type: this.alterTableKeyType
       });
       alterTableName = this.alterTableName;
     }
-------------- next part --------------
HTML$B$NE:IU%U%!%$%k$rJ]4I$7$^$7$?(B...
Download 



Groonga-commit メーリングリストの案内
Back to archive index