Fix ReloadAll 0 value primary key collisions

This commit is contained in:
Patrick O'brien 2016-08-09 10:34:21 +10:00
parent fa8e431349
commit b9fc5e4080
2 changed files with 3 additions and 3 deletions

View file

@ -105,7 +105,7 @@ func (o *{{$tableNameSingular}}) Insert(exec boil.Executor, whitelist ... string
// - add all columns that have a default in the database but that are non-zero in the struct
// - the return columns are the result of (columns with default values - the previous set)
func (o *{{$tableNameSingular}}) generateInsertColumns(whitelist ...string) ([]string, []string) {
if len(whitelist) != 0 {
if len(whitelist) > 0 {
return whitelist, boil.SetComplement({{$varNameSingular}}ColumnsWithDefault, whitelist)
}

View file

@ -46,7 +46,7 @@ func Test{{$tableNamePlural}}ReloadAll(t *testing.T) {
o1 := make({{$tableNameSingular}}Slice, 3)
o2 := make({{$tableNameSingular}}Slice, 3)
if err = boil.RandomizeSlice(&o1, {{$varNameSingular}}DBTypes, true); err != nil {
if err = boil.RandomizeSlice(&o1, {{$varNameSingular}}DBTypes, false); err != nil {
t.Errorf("Unable to randomize {{$tableNameSingular}} slice: %s", err)
}
@ -66,7 +66,7 @@ func Test{{$tableNamePlural}}ReloadAll(t *testing.T) {
}
// Randomize the struct values again, except for the primary key values, so we can call update.
err = boil.RandomizeSlice(&o1, {{$varNameSingular}}DBTypes, true, {{$varNameSingular}}PrimaryKeyColumns...)
err = boil.RandomizeSlice(&o1, {{$varNameSingular}}DBTypes, false, {{$varNameSingular}}PrimaryKeyColumns...)
if err != nil {
t.Errorf("Unable to randomize {{$tableNameSingular}} slice excluding primary keys: %s", err)
}