diff --git a/orm/callback_create.go b/orm/callback_create.go index b300166..b80abe3 100644 --- a/orm/callback_create.go +++ b/orm/callback_create.go @@ -117,10 +117,20 @@ func createCallback(scope *Scope) { } } } else { - if err := scope.SQLDB().QueryRow(scope.SQL, scope.SQLVars...).Scan(primaryField.Field.Addr().Interface()); scope.Err(err) == nil { - primaryField.IsBlank = false - scope.db.RowsAffected = 1 + + if scope.Dialect().GetName() == "h2" { + _, err := scope.SQLDB().Exec(scope.SQL, scope.SQLVars...) + if scope.Err(err) == nil { + primaryField.IsBlank = false + scope.db.RowsAffected = 1 + } + } else { + if err := scope.SQLDB().QueryRow(scope.SQL, scope.SQLVars...).Scan(primaryField.Field.Addr().Interface()); scope.Err(err) == nil { + primaryField.IsBlank = false + scope.db.RowsAffected = 1 + } } + } } } diff --git a/orm/dialect_h2.go b/orm/dialect_h2.go index dd00525..0f14f8b 100644 --- a/orm/dialect_h2.go +++ b/orm/dialect_h2.go @@ -114,12 +114,13 @@ 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(" ; ") } func (h2) SupportLastInsertID() bool { return false } + // //func isByteArrayOrSlice(value reflect.Value) bool { // return (value.Kind() == reflect.Array || value.Kind() == reflect.Slice) && value.Type().Elem() == reflect.TypeOf(uint8(0))