Skip to content

Commit fdfe578

Browse files
committed
Fix nil panic when schema doesn't exist, close #67
1 parent 5f93fbb commit fdfe578

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ func Create(db *gorm.DB) {
118118
}
119119

120120
if !db.DryRun && db.Error == nil {
121-
if len(db.Statement.Schema.FieldsWithDefaultDBValue) > 0 {
121+
if db.Statement.Schema != nil && len(db.Statement.Schema.FieldsWithDefaultDBValue) > 0 {
122122
rows, err := db.Statement.ConnPool.QueryContext(db.Statement.Context, db.Statement.SQL.String(), db.Statement.Vars...)
123123
if db.AddError(err) == nil {
124124
defer rows.Close()

0 commit comments

Comments
 (0)