1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-26 03:01:28 +00:00

orm: fix postgres returning id error

This commit is contained in:
miraclesu 2016-03-24 20:03:45 +08:00
parent eaf38bb096
commit 3e2ffa545f

View File

@ -123,14 +123,16 @@ func (d *dbBasePostgres) ReplaceMarks(query *string) {
} }
// make returning sql support for postgresql. // make returning sql support for postgresql.
func (d *dbBasePostgres) HasReturningID(mi *modelInfo, query *string) (has bool) { func (d *dbBasePostgres) HasReturningID(mi *modelInfo, query *string) bool {
if mi.fields.pk.auto { fi := mi.fields.pk
if query != nil { if fi.fieldType&IsPositiveIntegerField == 0 && fi.fieldType&IsIntegerField == 0 {
*query = fmt.Sprintf(`%s RETURNING "%s"`, *query, mi.fields.pk.column) return false
}
has = true
} }
return
if query != nil {
*query = fmt.Sprintf(`%s RETURNING "%s"`, *query, fi.column)
}
return true
} }
// show table sql for postgresql. // show table sql for postgresql.