Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions boilingcore/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,10 @@ 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,
"aliasCols": func(ta TableAlias) func(string) string { return ta.Column },
"usesPrimitives": usesPrimitives,
"isPrimitive": isPrimitive,
"isNullPrimitive": isNullPrimitive,
"splitLines": func(a string) []string {
if a == "" {
return nil
Expand Down
16 changes: 16 additions & 0 deletions boilingcore/text_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,19 @@ func isPrimitive(typ string) bool {

return false
}

func isNullPrimitive(typ string) bool {
switch typ {
// Numeric
case "null.Int", "null.Int8", "null.Int16", "null.Int32", "null.Int64":
return true
case "null.Uint", "null.Uint8", "null.Uint16", "null.Uint32", "null.Uint64":
return true
case "null.Float32", "null.Float64":
return true
case "null.Byte", "null.String":
return true
}

return false
}
6 changes: 3 additions & 3 deletions templatebin/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion templates/00_struct.go.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (w {{$name}}) LT(x {{.Type}}) qm.QueryMod { return qmhelper.Where(w.field,
func (w {{$name}}) LTE(x {{.Type}}) qm.QueryMod { return qmhelper.Where(w.field, qmhelper.LTE, x) }
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 isPrimitive .Type -}}
{{if or (isPrimitive .Type) (isNullPrimitive .Type) -}}
func (w {{$name}}) IN(slice []{{.Type}}) qm.QueryMod {
values := make([]interface{}, 0, len(slice))
for _, value := range slice {
Expand Down