mssql: use SCOPE_IDENTITY() if OUTPUT not possible
This commit is contained in:
parent
26c261fb13
commit
ae79e179fb
@ -100,8 +100,11 @@ func createCallback(scope *Scope) {
|
||||
returningColumn = scope.Quote(primaryField.DBName)
|
||||
}
|
||||
|
||||
lastInsertIDReturningSuffix := scope.Dialect().LastInsertIDReturningSuffix(quotedTableName, returningColumn)
|
||||
lastInsertIDOutputInterstitial := scope.Dialect().LastInsertIDOutputInterstitial(quotedTableName, returningColumn, columns)
|
||||
var lastInsertIDReturningSuffix string
|
||||
if lastInsertIDOutputInterstitial == "" {
|
||||
lastInsertIDReturningSuffix = scope.Dialect().LastInsertIDReturningSuffix(quotedTableName, returningColumn)
|
||||
}
|
||||
|
||||
if len(columns) == 0 {
|
||||
scope.Raw(fmt.Sprintf(
|
||||
|
@ -207,7 +207,8 @@ func (mssql) LastInsertIDOutputInterstitial(tableName, columnName string, column
|
||||
}
|
||||
|
||||
func (mssql) LastInsertIDReturningSuffix(tableName, columnName string) string {
|
||||
return ""
|
||||
// https://stackoverflow.com/questions/5228780/how-to-get-last-inserted-id
|
||||
return "; SELECT SCOPE_IDENTITY()"
|
||||
}
|
||||
|
||||
func (mssql) DefaultValueStr() string {
|
||||
|
Loading…
x
Reference in New Issue
Block a user