Closed jimmyduang closed 2 years ago
Can we use
pg_class/pg_attribute
tables to get index information instead of regexp matching? probably likeselect t.relname as table_name, i.relname as index_name, a.attname as column_name, ix.indisunique as indisunique from pg_class t, pg_class i, pg_index ix, pg_attribute a where t.oid = ix.indrelid and i.oid = ix.indexrelid and a.attrelid = t.oid and a.attnum = ANY(ix.indkey) and t.relkind = 'r' and t.relname like 'user%'
https://stackoverflow.com/questions/2204058/list-columns-with-indexes-in-postgresql
OK,i will try
@a631807682 done
@a631807682 hi,bro. I just modify base of this pr https://github.com/go-gorm/mysql/pull/77/commits/b5cef9cfeba8a4d713b416c6a3d1bb2d513db0a3 . In order to keep the codes on both sides consistent, if it is necessary to strict, I will improve it
@a631807682 hi,bro. I just modify base of this pr go-gorm/mysql@b5cef9c . In order to keep the codes on both sides consistent, if it is necessary to strict, I will improve it
sql: converting argument $2 type: unsupported type mysql.Migrator, a struct
@a631807682 hi,bro. I just modify base of this pr go-gorm/mysql@b5cef9c . In order to keep the codes on both sides consistent, if it is necessary to strict, I will improve it
- Each driver only needs to be consistent through the interface
- go-gorm/mysql@b5cef9c not work for me, it throw
sql: converting argument $2 type: unsupported type mysql.Migrator, a struct
- We will usually be strict because every PR may be referenced, resulting in a cumulative impact of unnecessary code that affects efficiency
- We'd be happy if you'd like to create a PR to fix the mysql problem
i see ,i will change my code,thx bro.
@a631807682 done
I suggest removing the judgment here, because we will not have empty records, just like we do not need to judge whether there are empty values in the list
after using list, err:=db.Find().Error
func groupByIndexName(indexList []*Index) map[string][]*Index {
columnIndexMap := make(map[string][]*Index, len(indexList))
for _, idx := range indexList {
if idx == nil { // I suggest removing the judgment here
continue
}
columnIndexMap[idx.IndexName] = append(columnIndexMap[idx.IndexName], idx)
}
return columnIndexMap
}
Others are fine for me.
Sorry for changing the review multiple times
it‘s ok
@a631807682 thx bro,please cr agin.
sorry mistake request...
LGTM, thank you @jimmyduang @a631807682 for your awesome work.
What did this pull request do?
Implement postgres Migrator GetIndexes func
User Case Description