updated for codacy requirements

This commit is contained in:
Jim Lambert 2020-02-18 10:34:09 -05:00
parent 7ee4ea18a8
commit a7f4ec52e7

View File

@ -276,7 +276,7 @@ func (s *OraCommon) DataTypeOf(field *StructField) string {
return fmt.Sprintf("%v %v", sqlType, additionalType) return fmt.Sprintf("%v %v", sqlType, additionalType)
} }
// LimitAddOffsetSQL returns the sql for limiting and offseting selects // LimitAndOffsetSQL returns the sql for limiting and offseting selects
func (s OraCommon) LimitAndOffsetSQL(limit, offset interface{}) (sql string, err error) { func (s OraCommon) LimitAndOffsetSQL(limit, offset interface{}) (sql string, err error) {
if limit != nil { if limit != nil {
if parsedLimit, err := strconv.ParseInt(fmt.Sprint(limit), 0, 0); err == nil && parsedLimit >= 0 { if parsedLimit, err := strconv.ParseInt(fmt.Sprint(limit), 0, 0); err == nil && parsedLimit >= 0 {
@ -303,17 +303,17 @@ func (OraCommon) NormalizeIndexAndColumn(indexName, columnName string) (string,
// CreateWithReturningInto to implement the OraDialect interface // CreateWithReturningInto to implement the OraDialect interface
func (OraCommon) CreateWithReturningInto(scope *Scope) { func (OraCommon) CreateWithReturningInto(scope *Scope) {
var stringId string var stringID string
var intId uint32 var intID uint32
primaryField := scope.PrimaryField() primaryField := scope.PrimaryField()
primaryIsString := false primaryIsString := false
out := sql.Out{ out := sql.Out{
Dest: &intId, Dest: &intID,
} }
if primaryField.Field.Kind() == reflect.String { if primaryField.Field.Kind() == reflect.String {
out = sql.Out{ out = sql.Out{
Dest: &stringId, Dest: &stringID,
} }
primaryIsString = true primaryIsString = true
} }
@ -322,9 +322,9 @@ func (OraCommon) CreateWithReturningInto(scope *Scope) {
if result, err := scope.SQLDB().Exec(scope.SQL, scope.SQLVars...); scope.Err(err) == nil { if result, err := scope.SQLDB().Exec(scope.SQL, scope.SQLVars...); scope.Err(err) == nil {
scope.DB().RowsAffected, _ = result.RowsAffected() scope.DB().RowsAffected, _ = result.RowsAffected()
if primaryIsString { if primaryIsString {
scope.Err(primaryField.Set(stringId)) scope.Err(primaryField.Set(stringID))
} else { } else {
scope.Err(primaryField.Set(intId)) scope.Err(primaryField.Set(intID))
} }
} }
// this should raise an error, but the gorm.createCallback() which calls it simply doesn't support returning an error // this should raise an error, but the gorm.createCallback() which calls it simply doesn't support returning an error