resolved #416
This commit is contained in:
parent
3d4a143814
commit
7d0f249cf5
12
engine.go
12
engine.go
|
@ -381,7 +381,7 @@ func (engine *Engine) DBMetas() ([]*core.Table, error) {
|
|||
for _, index := range indexes {
|
||||
for _, name := range index.Cols {
|
||||
if col := table.GetColumn(name); col != nil {
|
||||
col.Indexes[index.Name] = true
|
||||
col.Indexes[index.Name] = index.Type
|
||||
} else {
|
||||
return nil, fmt.Errorf("Unknown col "+name+" in indexes %v of table", index, table.ColumnsSeq())
|
||||
}
|
||||
|
@ -876,12 +876,12 @@ func (engine *Engine) TableInfo(bean interface{}) *core.Table {
|
|||
func addIndex(indexName string, table *core.Table, col *core.Column, indexType int) {
|
||||
if index, ok := table.Indexes[indexName]; ok {
|
||||
index.AddColumn(col.Name)
|
||||
col.Indexes[index.Name] = true
|
||||
col.Indexes[index.Name] = indexType
|
||||
} else {
|
||||
index := core.NewIndex(indexName, indexType)
|
||||
index.AddColumn(col.Name)
|
||||
table.AddIndex(index)
|
||||
col.Indexes[index.Name] = true
|
||||
col.Indexes[index.Name] = indexType
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -930,7 +930,7 @@ func (engine *Engine) mapType(v reflect.Value) *core.Table {
|
|||
|
||||
if ormTagStr != "" {
|
||||
col = &core.Column{FieldName: t.Field(i).Name, Nullable: true, IsPrimaryKey: false,
|
||||
IsAutoIncrement: false, MapType: core.TWOSIDES, Indexes: make(map[string]bool)}
|
||||
IsAutoIncrement: false, MapType: core.TWOSIDES, Indexes: make(map[string]int)}
|
||||
tags := splitTag(ormTagStr)
|
||||
|
||||
if len(tags) > 0 {
|
||||
|
@ -954,8 +954,10 @@ func (engine *Engine) mapType(v reflect.Value) *core.Table {
|
|||
for _, col := range parentTable.Columns() {
|
||||
col.FieldName = fmt.Sprintf("%v.%v", t.Field(i).Name, col.FieldName)
|
||||
table.AddColumn(col)
|
||||
for indexName, indexType := range col.Indexes {
|
||||
addIndex(indexName, table, col, indexType)
|
||||
}
|
||||
}
|
||||
|
||||
continue
|
||||
default:
|
||||
//TODO: warning
|
||||
|
|
|
@ -352,7 +352,7 @@ where a.object_id=object_id('` + tableName + `')`
|
|||
}
|
||||
|
||||
col := new(core.Column)
|
||||
col.Indexes = make(map[string]bool)
|
||||
col.Indexes = make(map[string]int)
|
||||
col.Length = maxLen
|
||||
col.Name = strings.Trim(name, "` ")
|
||||
|
||||
|
|
|
@ -311,7 +311,7 @@ func (db *mysql) GetColumns(tableName string) ([]string, map[string]*core.Column
|
|||
colSeq := make([]string, 0)
|
||||
for rows.Next() {
|
||||
col := new(core.Column)
|
||||
col.Indexes = make(map[string]bool)
|
||||
col.Indexes = make(map[string]int)
|
||||
|
||||
var columnName, isNullable, colType, colKey, extra string
|
||||
var colDefault *string
|
||||
|
|
|
@ -692,7 +692,7 @@ func (db *oracle) GetColumns(tableName string) ([]string, map[string]*core.Colum
|
|||
colSeq := make([]string, 0)
|
||||
for rows.Next() {
|
||||
col := new(core.Column)
|
||||
col.Indexes = make(map[string]bool)
|
||||
col.Indexes = make(map[string]int)
|
||||
|
||||
var colName, colDefault, nullable, dataType, dataPrecision, dataScale *string
|
||||
var dataLen int
|
||||
|
|
|
@ -936,7 +936,7 @@ WHERE c.relkind = 'r'::char AND c.relname = $1 AND s.table_schema = $2 AND f.att
|
|||
|
||||
for rows.Next() {
|
||||
col := new(core.Column)
|
||||
col.Indexes = make(map[string]bool)
|
||||
col.Indexes = make(map[string]int)
|
||||
|
||||
var colName, isNullable, dataType string
|
||||
var maxLenStr, colDefault, numPrecision, numRadix *string
|
||||
|
|
|
@ -311,7 +311,7 @@ func (db *sqlite3) GetColumns(tableName string) ([]string, map[string]*core.Colu
|
|||
colStr = reg.ReplaceAllString(colStr, ",")
|
||||
fields := strings.Fields(strings.TrimSpace(colStr))
|
||||
col := new(core.Column)
|
||||
col.Indexes = make(map[string]bool)
|
||||
col.Indexes = make(map[string]int)
|
||||
col.Nullable = true
|
||||
col.DefaultIsEmpty = true
|
||||
for idx, field := range fields {
|
||||
|
|
Loading…
Reference in New Issue