Skip to content

Commit

Permalink
fix: handle database type array (#115)
Browse files Browse the repository at this point in the history
* fix: handle database type array

* chore: code comment
  • Loading branch information
a631807682 committed Jul 4, 2022
1 parent c2cfceb commit 237572f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions migrator.go
Expand Up @@ -478,6 +478,12 @@ func (m Migrator) ColumnTypes(value interface{}) (columnTypes []gorm.ColumnType,
mc := c.(*migrator.ColumnType)
if mc.NameValue.String == name {
mc.ColumnTypeValue = sql.NullString{String: dataType, Valid: true}
// Handle array type: _text -> text[] , _int4 -> integer[]
// Not support array size limits and array size limits because:
// https://www.postgresql.org/docs/current/arrays.html#ARRAYS-DECLARATION
if strings.HasPrefix(mc.DataTypeValue.String, "_") {
mc.DataTypeValue = sql.NullString{String: dataType, Valid: true}
}
break
}
}
Expand Down

0 comments on commit 237572f

Please sign in to comment.