susumu.yata
null+****@clear*****
Tue Jun 23 15:33:25 JST 2015
susumu.yata 2015-06-23 15:33:25 +0900 (Tue, 23 Jun 2015) New Revision: 9c0288ae01cefa5e8525fbee8db1226f93d5eeed https://github.com/groonga/grngo/commit/9c0288ae01cefa5e8525fbee8db1226f93d5eeed Message: Use HashTable as the default option. TableType is disabled if KeyType is empty. GitHub: #7 Modified files: grngo.go Modified: grngo.go (+15 -10) =================================================================== --- grngo.go 2015-06-23 10:31:53 +0900 (0ec5d56) +++ grngo.go 2015-06-23 15:33:25 +0900 (bb2837a) @@ -119,6 +119,7 @@ type TableOptions struct { // settings. func NewTableOptions() *TableOptions { var options TableOptions + options.TableType = HashTable return &options } @@ -383,17 +384,21 @@ func (db *DB) CreateTable(name string, options *TableOptions) (*Table, error) { } optionsMap := make(map[string]string) optionsMap["name"] = name - switch options.TableType { - case ArrayTable: + if options.KeyType == "" { optionsMap["flags"] = "TABLE_NO_KEY" - case HashTable: - optionsMap["flags"] = "TABLE_HASH_KEY" - case PatTable: - optionsMap["flags"] = "TABLE_PAT_KEY" - case DatTable: - optionsMap["flags"] = "TABLE_DAT_KEY" - default: - return nil, fmt.Errorf("undefined table type: options = %+v", options) + } else { + switch options.TableType { + case ArrayTable: + optionsMap["flags"] = "TABLE_NO_KEY" + case HashTable: + optionsMap["flags"] = "TABLE_HASH_KEY" + case PatTable: + optionsMap["flags"] = "TABLE_PAT_KEY" + case DatTable: + optionsMap["flags"] = "TABLE_DAT_KEY" + default: + return nil, fmt.Errorf("undefined table type: options = %+v", options) + } } if options.WithSIS { optionsMap["flags"] += "|KEY_WITH_SIS" -------------- next part -------------- HTML����������������������������...Descargar