@@ -212,7 +212,7 @@ func (t tmplField) ConditionZero() string {
212212 return ` != ""`
213213 case "time.Time" , "*time.Time" , "sql.NullTime" : //nolint
214214 return ` != nil && table.` + t .Name + `.IsZero() == false`
215- case "[]byte" , "[]string" , "[]int" , " interface{}" : //nolint
215+ case "interface{}" : //nolint
216216 return ` != nil` //nolint
217217 case "bool" : //nolint
218218 return ` != false`
@@ -222,12 +222,13 @@ func (t tmplField) ConditionZero() string {
222222 if t .GoType == goTypeOID {
223223 return ` != primitive.NilObjectID`
224224 }
225- if t .GoType == "*" + t .Name {
226- return ` != nil` //nolint
227- }
228- if strings .Contains (t .GoType , "[]" ) {
229- return ` != nil` //nolint
230- }
225+ }
226+
227+ if t .GoType == "*" + t .Name {
228+ return ` != nil` //nolint
229+ }
230+ if strings .Contains (t .GoType , "[]" ) {
231+ return ` != nil && len(table.` + t .Name + `) > 0` //nolint
231232 }
232233
233234 if t .GoType == "" {
@@ -686,9 +687,6 @@ func getModelStructCode(data tmplData, importPaths []string, isEmbed bool, jsonN
686687 }
687688 if field .rewriterField != nil {
688689 switch field .rewriterField .goType {
689- //case jsonTypeName, decimalTypeName:
690- // field.GoType = field.rewriterField.goType
691- // importPaths = append(importPaths, field.rewriterField.path)
692690 case jsonTypeName , decimalTypeName , boolTypeName , boolTypeTinyName :
693691 field .GoType = "*" + field .rewriterField .goType
694692 importPaths = append (importPaths , field .rewriterField .path )
@@ -716,6 +714,9 @@ func getModelStructCode(data tmplData, importPaths []string, isEmbed bool, jsonN
716714 newImportPaths = append (newImportPaths , "github.com/go-dev-frame/sponge/pkg/sgorm" )
717715 } else {
718716 for _ , field := range data .Fields {
717+ if strings .Contains (field .GoType , "time.Time" ) {
718+ field .GoType = "*time.Time"
719+ }
719720 switch field .DBDriver {
720721 case DBDriverMongodb :
721722 if field .Name == "ID" {
@@ -724,9 +725,6 @@ func getModelStructCode(data tmplData, importPaths []string, isEmbed bool, jsonN
724725 }
725726
726727 default :
727- if strings .Contains (field .GoType , "time.Time" ) {
728- field .GoType = "*time.Time"
729- }
730728 // force conversion of ID field to uint64 type
731729 if field .Name == "ID" {
732730 field .GoType = "uint64"
@@ -737,9 +735,6 @@ func getModelStructCode(data tmplData, importPaths []string, isEmbed bool, jsonN
737735 if field .DBDriver == DBDriverMysql || field .DBDriver == DBDriverPostgresql || field .DBDriver == DBDriverTidb {
738736 if field .rewriterField != nil {
739737 switch field .rewriterField .goType {
740- //case jsonTypeName, decimalTypeName:
741- // field.GoType = field.rewriterField.goType
742- // importPaths = append(importPaths, field.rewriterField.path)
743738 case jsonTypeName , decimalTypeName , boolTypeName , boolTypeTinyName :
744739 field .GoType = "*" + field .rewriterField .goType
745740 importPaths = append (importPaths , field .rewriterField .path )
0 commit comments