Skip to content

Commit

Permalink
Fix nil panic when schema doesn't exist, close #67
Browse files Browse the repository at this point in the history
  • Loading branch information
jinzhu committed Oct 8, 2022
1 parent 5f93fbb commit fdfe578
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion create.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func Create(db *gorm.DB) {
}

if !db.DryRun && db.Error == nil {
if len(db.Statement.Schema.FieldsWithDefaultDBValue) > 0 {
if db.Statement.Schema != nil && len(db.Statement.Schema.FieldsWithDefaultDBValue) > 0 {
rows, err := db.Statement.ConnPool.QueryContext(db.Statement.Context, db.Statement.SQL.String(), db.Statement.Vars...)
if db.AddError(err) == nil {
defer rows.Close()
Expand Down

0 comments on commit fdfe578

Please sign in to comment.