bug fixed for mssql dialect
This commit is contained in:
parent
7e70eb8222
commit
a5cb21c443
|
@ -216,9 +216,9 @@ func (db *mssql) SqlType(c *core.Column) string {
|
||||||
switch t := c.SQLType.Name; t {
|
switch t := c.SQLType.Name; t {
|
||||||
case core.Bool:
|
case core.Bool:
|
||||||
res = core.TinyInt
|
res = core.TinyInt
|
||||||
if c.Default == "true" {
|
if strings.EqualFold(c.Default, "true") {
|
||||||
c.Default = "1"
|
c.Default = "1"
|
||||||
} else if c.Default == "false" {
|
} else {
|
||||||
c.Default = "0"
|
c.Default = "0"
|
||||||
}
|
}
|
||||||
case core.Serial:
|
case core.Serial:
|
||||||
|
@ -468,9 +468,10 @@ WHERE IXS.TYPE_DESC='NONCLUSTERED' and OBJECT_NAME(IXS.OBJECT_ID) =?
|
||||||
}
|
}
|
||||||
|
|
||||||
colName = strings.Trim(colName, "` ")
|
colName = strings.Trim(colName, "` ")
|
||||||
|
var isRegular bool
|
||||||
if strings.HasPrefix(indexName, "IDX_"+tableName) || strings.HasPrefix(indexName, "UQE_"+tableName) {
|
if strings.HasPrefix(indexName, "IDX_"+tableName) || strings.HasPrefix(indexName, "UQE_"+tableName) {
|
||||||
indexName = indexName[5+len(tableName):]
|
indexName = indexName[5+len(tableName):]
|
||||||
|
isRegular = true
|
||||||
}
|
}
|
||||||
|
|
||||||
var index *core.Index
|
var index *core.Index
|
||||||
|
@ -479,6 +480,7 @@ WHERE IXS.TYPE_DESC='NONCLUSTERED' and OBJECT_NAME(IXS.OBJECT_ID) =?
|
||||||
index = new(core.Index)
|
index = new(core.Index)
|
||||||
index.Type = indexType
|
index.Type = indexType
|
||||||
index.Name = indexName
|
index.Name = indexName
|
||||||
|
index.IsRegular = isRegular
|
||||||
indexes[indexName] = index
|
indexes[indexName] = index
|
||||||
}
|
}
|
||||||
index.AddColumn(colName)
|
index.AddColumn(colName)
|
||||||
|
|
|
@ -824,6 +824,12 @@ func (db *oracle) GetIndexes(tableName string) (map[string]*core.Index, error) {
|
||||||
|
|
||||||
indexName = strings.Trim(indexName, `" `)
|
indexName = strings.Trim(indexName, `" `)
|
||||||
|
|
||||||
|
var isRegular bool
|
||||||
|
if strings.HasPrefix(indexName, "IDX_"+tableName) || strings.HasPrefix(indexName, "UQE_"+tableName) {
|
||||||
|
indexName = indexName[5+len(tableName):]
|
||||||
|
isRegular = true
|
||||||
|
}
|
||||||
|
|
||||||
if uniqueness == "UNIQUE" {
|
if uniqueness == "UNIQUE" {
|
||||||
indexType = core.UniqueType
|
indexType = core.UniqueType
|
||||||
} else {
|
} else {
|
||||||
|
@ -836,6 +842,7 @@ func (db *oracle) GetIndexes(tableName string) (map[string]*core.Index, error) {
|
||||||
index = new(core.Index)
|
index = new(core.Index)
|
||||||
index.Type = indexType
|
index.Type = indexType
|
||||||
index.Name = indexName
|
index.Name = indexName
|
||||||
|
index.IsRegular = isRegular
|
||||||
indexes[indexName] = index
|
indexes[indexName] = index
|
||||||
}
|
}
|
||||||
index.AddColumn(colName)
|
index.AddColumn(colName)
|
||||||
|
|
|
@ -1078,9 +1078,10 @@ func (db *postgres) GetIndexes(tableName string) (map[string]*core.Index, error)
|
||||||
}
|
}
|
||||||
cs := strings.Split(indexdef, "(")
|
cs := strings.Split(indexdef, "(")
|
||||||
colNames = strings.Split(cs[1][0:len(cs[1])-1], ",")
|
colNames = strings.Split(cs[1][0:len(cs[1])-1], ",")
|
||||||
|
var isRegular bool
|
||||||
if strings.HasPrefix(indexName, "IDX_"+tableName) || strings.HasPrefix(indexName, "UQE_"+tableName) {
|
if strings.HasPrefix(indexName, "IDX_"+tableName) || strings.HasPrefix(indexName, "UQE_"+tableName) {
|
||||||
newIdxName := indexName[5+len(tableName):]
|
newIdxName := indexName[5+len(tableName):]
|
||||||
|
isRegular = true
|
||||||
if newIdxName != "" {
|
if newIdxName != "" {
|
||||||
indexName = newIdxName
|
indexName = newIdxName
|
||||||
}
|
}
|
||||||
|
@ -1090,6 +1091,7 @@ func (db *postgres) GetIndexes(tableName string) (map[string]*core.Index, error)
|
||||||
for _, colName := range colNames {
|
for _, colName := range colNames {
|
||||||
index.Cols = append(index.Cols, strings.Trim(colName, `" `))
|
index.Cols = append(index.Cols, strings.Trim(colName, `" `))
|
||||||
}
|
}
|
||||||
|
index.IsRegular = isRegular
|
||||||
indexes[index.Name] = index
|
indexes[index.Name] = index
|
||||||
}
|
}
|
||||||
return indexes, nil
|
return indexes, nil
|
||||||
|
|
|
@ -405,8 +405,10 @@ func (db *sqlite3) GetIndexes(tableName string) (map[string]*core.Index, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
indexName := strings.Trim(sql[nNStart+6:nNEnd], "` []")
|
indexName := strings.Trim(sql[nNStart+6:nNEnd], "` []")
|
||||||
|
var isRegular bool
|
||||||
if strings.HasPrefix(indexName, "IDX_"+tableName) || strings.HasPrefix(indexName, "UQE_"+tableName) {
|
if strings.HasPrefix(indexName, "IDX_"+tableName) || strings.HasPrefix(indexName, "UQE_"+tableName) {
|
||||||
index.Name = indexName[5+len(tableName):]
|
index.Name = indexName[5+len(tableName):]
|
||||||
|
isRegular = true
|
||||||
} else {
|
} else {
|
||||||
index.Name = indexName
|
index.Name = indexName
|
||||||
}
|
}
|
||||||
|
@ -425,6 +427,7 @@ func (db *sqlite3) GetIndexes(tableName string) (map[string]*core.Index, error)
|
||||||
for _, col := range colIndexes {
|
for _, col := range colIndexes {
|
||||||
index.Cols = append(index.Cols, strings.Trim(col, "` []"))
|
index.Cols = append(index.Cols, strings.Trim(col, "` []"))
|
||||||
}
|
}
|
||||||
|
index.IsRegular = isRegular
|
||||||
indexes[index.Name] = index
|
indexes[index.Name] = index
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue