Skip to content

Commit c37aff9

Browse files
Guillermo Prandiguillep2klunny
committed
Exclude schema from index name (#1505)
Merge branch 'master' into fix-schema-idx SetExpr support more go types (#1499) Improve tests SetExpr support more go types fix vet fix drone lint remove go1.10 test on drone Reviewed-on: https://gitea.com/xorm/xorm/pulls/1499 fix vet fix drone lint remove go1.10 test on drone Exclude schema from the index name Co-authored-by: Guillermo Prandi <[email protected]> Co-authored-by: Lunny Xiao <[email protected]> Reviewed-on: https://gitea.com/xorm/xorm/pulls/1505
1 parent a18e35f commit c37aff9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

dialect_postgres.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ func (db *postgres) TableCheckSql(tableName string) (string, []interface{}) {
901901
}
902902

903903
func (db *postgres) ModifyColumnSql(tableName string, col *core.Column) string {
904-
if len(db.Schema) == 0 {
904+
if len(db.Schema) == 0 || strings.Contains(tableName, ".") {
905905
return fmt.Sprintf("alter table %s ALTER COLUMN %s TYPE %s",
906906
tableName, col.Name, db.SqlType(col))
907907
}
@@ -913,8 +913,8 @@ func (db *postgres) DropIndexSql(tableName string, index *core.Index) string {
913913
quote := db.Quote
914914
idxName := index.Name
915915

916-
tableName = strings.Replace(tableName, `"`, "", -1)
917-
tableName = strings.Replace(tableName, `.`, "_", -1)
916+
tableParts := strings.Split(strings.Replace(tableName, `"`, "", -1), ".")
917+
tableName = tableParts[len(tableParts)-1]
918918

919919
if !strings.HasPrefix(idxName, "UQE_") &&
920920
!strings.HasPrefix(idxName, "IDX_") {

0 commit comments

Comments
 (0)