mirror of
https://github.com/astaxie/beego.git
synced 2024-11-25 20:20:54 +00:00
Merge pull request #1379 from pjoe/non_int_fk
orm: Fix handling of rel(fk) to model with string pk
This commit is contained in:
commit
a257a924a1
@ -45,13 +45,14 @@ func getDbDropSQL(al *alias) (sqls []string) {
|
|||||||
func getColumnTyp(al *alias, fi *fieldInfo) (col string) {
|
func getColumnTyp(al *alias, fi *fieldInfo) (col string) {
|
||||||
T := al.DbBaser.DbTypes()
|
T := al.DbBaser.DbTypes()
|
||||||
fieldType := fi.fieldType
|
fieldType := fi.fieldType
|
||||||
|
fieldSize := fi.size
|
||||||
|
|
||||||
checkColumn:
|
checkColumn:
|
||||||
switch fieldType {
|
switch fieldType {
|
||||||
case TypeBooleanField:
|
case TypeBooleanField:
|
||||||
col = T["bool"]
|
col = T["bool"]
|
||||||
case TypeCharField:
|
case TypeCharField:
|
||||||
col = fmt.Sprintf(T["string"], fi.size)
|
col = fmt.Sprintf(T["string"], fieldSize)
|
||||||
case TypeTextField:
|
case TypeTextField:
|
||||||
col = T["string-text"]
|
col = T["string-text"]
|
||||||
case TypeDateField:
|
case TypeDateField:
|
||||||
@ -89,6 +90,7 @@ checkColumn:
|
|||||||
}
|
}
|
||||||
case RelForeignKey, RelOneToOne:
|
case RelForeignKey, RelOneToOne:
|
||||||
fieldType = fi.relModelInfo.fields.pk.fieldType
|
fieldType = fi.relModelInfo.fields.pk.fieldType
|
||||||
|
fieldSize = fi.relModelInfo.fields.pk.size
|
||||||
goto checkColumn
|
goto checkColumn
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user