From e4988b714ec3f3fc7c960a5253f0e63625137eba Mon Sep 17 00:00:00 2001 From: supar Date: Fri, 17 Oct 2014 12:27:53 +0400 Subject: [PATCH] Add property colDefault to fieldInfo object, set its true if there is orm configuration default `orm:"default(1)"` --- orm/models_info_f.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/orm/models_info_f.go b/orm/models_info_f.go index a79ffab2..84a0c024 100644 --- a/orm/models_info_f.go +++ b/orm/models_info_f.go @@ -116,6 +116,7 @@ type fieldInfo struct { null bool index bool unique bool + colDefault bool initial StrTo size int auto_now bool @@ -280,6 +281,11 @@ checkType: fi.pk = attrs["pk"] fi.unique = attrs["unique"] + // Mark object property if there is attribute "default" in the orm configuration + if _, ok := tags["default"]; ok { + fi.colDefault = true + } + switch fieldType { case RelManyToMany, RelReverseMany, RelReverseOne: fi.null = false