diff --git a/boilingcore/templates.go b/boilingcore/templates.go index ccc125946..6a346a7a8 100644 --- a/boilingcore/templates.go +++ b/boilingcore/templates.go @@ -312,11 +312,11 @@ var templateFunctions = template.FuncMap{ "whereClause": strmangle.WhereClause, // Alias and text helping - "aliasCols": func(ta TableAlias) func(string) string { return ta.Column }, - "usesPrimitives": usesPrimitives, - "isPrimitive": isPrimitive, - "isNullPrimitive": isNullPrimitive, - "toPrimitive": toPrimitive, + "aliasCols": func(ta TableAlias) func(string) string { return ta.Column }, + "usesPrimitives": usesPrimitives, + "isPrimitive": isPrimitive, + "isNullPrimitive": isNullPrimitive, + "convertNullToPrimitive": convertNullToPrimitive, "splitLines": func(a string) []string { if a == "" { return nil diff --git a/boilingcore/text_helpers.go b/boilingcore/text_helpers.go index 384f34f81..7803f7063 100644 --- a/boilingcore/text_helpers.go +++ b/boilingcore/text_helpers.go @@ -168,12 +168,11 @@ func isNullPrimitive(typ string) bool { return false } -// toPrimitive takes a type name and returns the underlying primitive type name X if it is a `null.X`, +// convertNullToPrimitive takes a type name and returns the underlying primitive type name X if it is a `null.X`, // otherwise it returns the input value unchanged -func toPrimitive(typ string) string { +func convertNullToPrimitive(typ string) string { if isNullPrimitive(typ) { return strings.ToLower(strings.Split(typ, ".")[1]) } return typ } - diff --git a/templates/main/00_struct.go.tpl b/templates/main/00_struct.go.tpl index 78ecb3837..1e23debdf 100644 --- a/templates/main/00_struct.go.tpl +++ b/templates/main/00_struct.go.tpl @@ -64,14 +64,14 @@ func (w {{$name}}) LTE(x {{.Type}}) qm.QueryMod { return qmhelper.Where(w.field, func (w {{$name}}) GT(x {{.Type}}) qm.QueryMod { return qmhelper.Where(w.field, qmhelper.GT, x) } func (w {{$name}}) GTE(x {{.Type}}) qm.QueryMod { return qmhelper.Where(w.field, qmhelper.GTE, x) } {{if or (isPrimitive .Type) (isNullPrimitive .Type) (isEnumDBType .DBType) -}} -func (w {{$name}}) IN(slice []{{toPrimitive .Type}}) qm.QueryMod { +func (w {{$name}}) IN(slice []{{convertNullToPrimitive .Type}}) qm.QueryMod { values := make([]interface{}, 0, len(slice)) for _, value := range slice { values = append(values, value) } return qm.WhereIn(fmt.Sprintf("%s IN ?", w.field), values...) } -func (w {{$name}}) NIN(slice []{{toPrimitive .Type}}) qm.QueryMod { +func (w {{$name}}) NIN(slice []{{convertNullToPrimitive .Type}}) qm.QueryMod { values := make([]interface{}, 0, len(slice)) for _, value := range slice { values = append(values, value)