feat: optimize ConvertSliceOfMapToValuesForCreate method
This commit is contained in:
parent
c0b910e7d3
commit
ad88cd9a30
@ -41,16 +41,21 @@ func ConvertMapToValuesForCreate(stmt *gorm.Statement, mapValue map[string]inter
|
||||
// ConvertSliceOfMapToValuesForCreate convert slice of map to values
|
||||
func ConvertSliceOfMapToValuesForCreate(stmt *gorm.Statement, mapValues []map[string]interface{}) (values clause.Values) {
|
||||
var (
|
||||
columns = make([]string, 0, len(mapValues))
|
||||
result = map[string][]interface{}{}
|
||||
selectColumns, restricted = stmt.SelectAndOmitColumns(true, false)
|
||||
columns = make([]string, 0, len(mapValues))
|
||||
)
|
||||
|
||||
// when the length of mapValues,return directly here
|
||||
// no need to call stmt.SelectAndOmitColumns method
|
||||
if len(mapValues) == 0 {
|
||||
stmt.AddError(gorm.ErrEmptySlice)
|
||||
return
|
||||
}
|
||||
|
||||
var (
|
||||
result = make(map[string][]interface{}, len(mapValues))
|
||||
selectColumns, restricted = stmt.SelectAndOmitColumns(true, false)
|
||||
)
|
||||
|
||||
for idx, mapValue := range mapValues {
|
||||
for k, v := range mapValue {
|
||||
if stmt.Schema != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user