From 896e8e9850bc61040eb04da13e9a090df6e4078b Mon Sep 17 00:00:00 2001 From: snoop Date: Tue, 8 Nov 2016 19:46:05 +0900 Subject: [PATCH] fixed h2 insert --- orm/callback_create.go | 2 +- orm/dialect_h2.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/orm/callback_create.go b/orm/callback_create.go index b80abe3..42dce66 100644 --- a/orm/callback_create.go +++ b/orm/callback_create.go @@ -119,7 +119,7 @@ func createCallback(scope *Scope) { } else { if scope.Dialect().GetName() == "h2" { - _, err := scope.SQLDB().Exec(scope.SQL, scope.SQLVars...) + _, err := scope.SQLDB().Query(scope.SQL, scope.SQLVars...) if scope.Err(err) == nil { primaryField.IsBlank = false scope.db.RowsAffected = 1 diff --git a/orm/dialect_h2.go b/orm/dialect_h2.go index 0f14f8b..75218ad 100644 --- a/orm/dialect_h2.go +++ b/orm/dialect_h2.go @@ -114,7 +114,7 @@ func (s h2) CurrentDatabase() (name string) { func (s h2) LastInsertIDReturningSuffix(tableName, key string) string { //return fmt.Sprintf("RETURNING %v.%v", tableName, key) - return fmt.Sprintf(" ; ") + return fmt.Sprintf(" ; CALL IDENTITY(); ") } func (h2) SupportLastInsertID() bool {