Compitable with cockroach (#1930)
Fix #1292 Reviewed-on: https://gitea.com/xorm/xorm/pulls/1930 Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
parent
7864cb5ae6
commit
a6d2bfb4ba
|
@ -1221,7 +1221,8 @@ func (db *postgres) GetIndexes(queryer core.Queryer, ctx context.Context, tableN
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
indexName = strings.Trim(indexName, `" `)
|
indexName = strings.Trim(indexName, `" `)
|
||||||
if strings.HasSuffix(indexName, "_pkey") {
|
// ignore primary index
|
||||||
|
if strings.HasSuffix(indexName, "_pkey") || strings.EqualFold(indexName, "primary") {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(indexdef, "CREATE UNIQUE INDEX") {
|
if strings.HasPrefix(indexdef, "CREATE UNIQUE INDEX") {
|
||||||
|
@ -1241,7 +1242,9 @@ func (db *postgres) GetIndexes(queryer core.Queryer, ctx context.Context, tableN
|
||||||
|
|
||||||
index := &schemas.Index{Name: indexName, Type: indexType, Cols: make([]string, 0)}
|
index := &schemas.Index{Name: indexName, Type: indexType, Cols: make([]string, 0)}
|
||||||
for _, colName := range colNames {
|
for _, colName := range colNames {
|
||||||
index.Cols = append(index.Cols, strings.TrimSpace(strings.Replace(colName, `"`, "", -1)))
|
col := strings.TrimSpace(strings.Replace(colName, `"`, "", -1))
|
||||||
|
fields := strings.Split(col, " ")
|
||||||
|
index.Cols = append(index.Cols, fields[0])
|
||||||
}
|
}
|
||||||
index.IsRegular = isRegular
|
index.IsRegular = isRegular
|
||||||
indexes[index.Name] = index
|
indexes[index.Name] = index
|
||||||
|
|
Loading…
Reference in New Issue