From 5daa413f418d8b745d5e7178b07405b0a215f5f2 Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Mon, 8 Nov 2021 20:20:55 +0800 Subject: [PATCH] Stabilize schema.FieldsWithDefaultDBValue's order, close #4643 --- schema/schema.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schema/schema.go b/schema/schema.go index ce7cf3b1..eca113e9 100644 --- a/schema/schema.go +++ b/schema/schema.go @@ -222,7 +222,7 @@ func ParseWithSpecialTableName(dest interface{}, cacheStore *sync.Map, namer Nam schema.PrimaryFieldDBNames = append(schema.PrimaryFieldDBNames, field.DBName) } - for _, field := range schema.FieldsByDBName { + for _, field := range schema.Fields { if field.HasDefaultValue && field.DefaultValueInterface == nil { schema.FieldsWithDefaultDBValue = append(schema.FieldsWithDefaultDBValue, field) }