diff --git a/callbacks/create.go b/callbacks/create.go index 6dc3f10a..cb161061 100644 --- a/callbacks/create.go +++ b/callbacks/create.go @@ -42,6 +42,7 @@ func Create(config *Config) func(db *gorm.DB) { } if db.Statement.SQL.String() == "" { + db.Statement.SQL.Grow(180) db.Statement.AddClauseIfNotExists(clause.Insert{ Table: clause.Table{Name: db.Statement.Table}, }) @@ -211,6 +212,7 @@ func ConvertToCreateValues(stmt *gorm.Statement) clause.Values { switch stmt.ReflectValue.Kind() { case reflect.Slice, reflect.Array: + stmt.SQL.Grow(stmt.ReflectValue.Len() * 15) values.Values = make([][]interface{}, stmt.ReflectValue.Len()) defaultValueFieldsHavingValue := map[string][]interface{}{} for i := 0; i < stmt.ReflectValue.Len(); i++ { diff --git a/callbacks/delete.go b/callbacks/delete.go index b246e69f..dea8bb5e 100644 --- a/callbacks/delete.go +++ b/callbacks/delete.go @@ -30,6 +30,7 @@ func Delete(db *gorm.DB) { } if db.Statement.SQL.String() == "" { + db.Statement.SQL.Grow(100) db.Statement.AddClauseIfNotExists(clause.Delete{}) if db.Statement.Schema != nil { diff --git a/callbacks/query.go b/callbacks/query.go index 571c7245..e5557d4a 100644 --- a/callbacks/query.go +++ b/callbacks/query.go @@ -37,6 +37,7 @@ func Query(db *gorm.DB) { } func BuildQuerySQL(db *gorm.DB) { + db.Statement.SQL.Grow(100) clauseSelect := clause.Select{Distinct: db.Statement.Distinct} if db.Statement.ReflectValue.Kind() == reflect.Struct { diff --git a/callbacks/update.go b/callbacks/update.go index 4ef33598..03d5c1e9 100644 --- a/callbacks/update.go +++ b/callbacks/update.go @@ -59,6 +59,7 @@ func Update(db *gorm.DB) { } if db.Statement.SQL.String() == "" { + db.Statement.SQL.Grow(180) db.Statement.AddClauseIfNotExists(clause.Update{}) if set := ConvertToAssignments(db.Statement); len(set) != 0 { db.Statement.AddClause(set)