mirror of https://github.com/go-gorm/gorm.git
Refactor callbacks
This commit is contained in:
parent
649d02fddd
commit
c4872cddfd
|
@ -193,22 +193,19 @@ func ConvertToCreateValues(stmt *gorm.Statement) clause.Values {
|
|||
return ConvertSliceOfMapToValuesForCreate(stmt, value)
|
||||
default:
|
||||
var (
|
||||
values = clause.Values{Columns: make([]clause.Column, len(stmt.Schema.DBNames))}
|
||||
values = clause.Values{Columns: make([]clause.Column, 0, len(stmt.Schema.DBNames))}
|
||||
selectColumns, restricted = SelectAndOmitColumns(stmt, true, false)
|
||||
curTime = stmt.DB.NowFunc()
|
||||
isZero = false
|
||||
)
|
||||
|
||||
var columns int
|
||||
for _, db := range stmt.Schema.DBNames {
|
||||
if field := stmt.Schema.FieldsByDBName[db]; !field.HasDefaultValue || field.DefaultValueInterface != nil {
|
||||
if v, ok := selectColumns[db]; (ok && v) || (!ok && !restricted) {
|
||||
values.Columns[columns] = clause.Column{Name: db}
|
||||
columns++
|
||||
values.Columns = append(values.Columns, clause.Column{Name: db})
|
||||
}
|
||||
}
|
||||
}
|
||||
values.Columns = values.Columns[:columns]
|
||||
|
||||
switch stmt.ReflectValue.Kind() {
|
||||
case reflect.Slice, reflect.Array:
|
||||
|
|
Loading…
Reference in New Issue