Filtering columns with auto values

This commit is contained in:
Sergey Kurt 2017-03-19 12:44:15 +03:00
parent 12dce9d986
commit d40d074320
2 changed files with 9 additions and 8 deletions

View file

@ -49,14 +49,13 @@ func (o *{{$tableNameSingular}}) Update(exec boil.Executor, whitelist ... string
if !cached {
wl := strmangle.UpdateColumnSet(
{{if ne .DriverName "mssql" -}}
{{$varNameSingular}}Columns,
{{- else -}}
{{$varNameSingular}}ColumnsWithoutAuto,
{{- end}}
{{$varNameSingular}}PrimaryKeyColumns,
whitelist,
)
{{if eq .DriverName "mssql"}}
wl = strmangle.SetComplement(wl, {{$varNameSingular}}ColumnsWithAuto)
{{end}}
{{- if not .NoAutoTimestamps}}
if len(whitelist) == 0 {
wl = strmangle.SetComplement(wl, []string{"created_at"})

View file

@ -79,13 +79,15 @@ func test{{$tableNamePlural}}SliceUpdateAll(t *testing.T) {
fields = {{$varNameSingular}}Columns
} else {
fields = strmangle.SetComplement(
{{if ne .DriverName "mssql" -}}
{{$varNameSingular}}Columns,
{{- else -}}
{{$varNameSingular}}ColumnsWithoutAuto,
{{- end}}
{{$varNameSingular}}PrimaryKeyColumns,
)
{{- if eq .DriverName "mssql"}}
fields = strmangle.SetComplement(
fields,
{{$varNameSingular}}ColumnsWithAuto,
)
{{- end}}
}
value := reflect.Indirect(reflect.ValueOf({{$varNameSingular}}))