h2 insert
This commit is contained in:
snoop 2016-11-08 19:11:00 +09:00
parent 9235703e7a
commit 0112f25f24
2 changed files with 15 additions and 4 deletions

View File

@ -117,11 +117,21 @@ func createCallback(scope *Scope) {
}
}
} else {
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
}
}
}
}
}

View File

@ -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))