Don't suppose id's value as int

This commit is contained in:
Jinzhu 2013-11-10 10:09:57 +08:00
parent 21713a5246
commit dc15849313
1 changed files with 3 additions and 3 deletions

6
do.go
View File

@ -93,7 +93,7 @@ func (s *Do) exec(sql ...string) {
s.err(err) s.err(err)
} }
func (s *Do) save() (i int64) { func (s *Do) save() (i interface{}) {
if s.model.primaryKeyZero() { if s.model.primaryKeyZero() {
return s.create() return s.create()
} else { } else {
@ -180,7 +180,7 @@ func (s *Do) saveAfterAssociations() {
} }
} }
func (s *Do) create() (i int64) { func (s *Do) create() (i interface{}) {
s.err(s.model.callMethod("BeforeCreate")) s.err(s.model.callMethod("BeforeCreate"))
s.err(s.model.callMethod("BeforeSave")) s.err(s.model.callMethod("BeforeSave"))
@ -188,7 +188,7 @@ func (s *Do) create() (i int64) {
s.prepareCreateSql() s.prepareCreateSql()
if !s.hasError() { if !s.hasError() {
var id int64 var id interface{}
if s.driver == "postgres" { if s.driver == "postgres" {
s.err(s.db.QueryRow(s.sql, s.sqlVars...).Scan(&id)) s.err(s.db.QueryRow(s.sql, s.sqlVars...).Scan(&id))
} else { } else {