From ba3e6201c72c22584cbe39f87a564c5ecdf440a6 Mon Sep 17 00:00:00 2001 From: Viktor Nikolaiev Date: Tue, 3 Oct 2017 17:17:39 +0300 Subject: [PATCH] fixed issue with null values in where conditions --- scope.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scope.go b/scope.go index 65d35461..252a1240 100644 --- a/scope.go +++ b/scope.go @@ -563,7 +563,7 @@ func (scope *Scope) buildWhereCondition(clause map[string]interface{}) (str stri var err error //non byte slice and non driver.Valuer - if rArgType.Kind() == reflect.Slice && rArgType.Elem().Kind() != reflect.Uint8 && !isValuer { + if arg != nil && rArgType.Kind() == reflect.Slice && rArgType.Elem().Kind() != reflect.Uint8 && !isValuer { if rArg.Len() > 0 { tempMarks := make([]string, 0, rArg.Len()) for i := 0; i < rArg.Len(); i++ { @@ -642,7 +642,7 @@ func (scope *Scope) buildNotCondition(clause map[string]interface{}) (str string var err error //non byte slice and non driver.Valuer - if rArgType.Kind() == reflect.Slice && rArgType.Elem().Kind() != reflect.Uint8 && !isValuer { + if arg != nil && rArgType.Kind() == reflect.Slice && rArgType.Elem().Kind() != reflect.Uint8 && !isValuer { if rArg.Len() > 0 { tempMarks := make([]string, 0, rArg.Len()) for i := 0; i < rArg.Len(); i++ { @@ -683,7 +683,7 @@ func (scope *Scope) buildSelectQuery(clause map[string]interface{}) (str string) var err error //non byte slice and non driver.Valuer - if rArgType.Kind() == reflect.Slice && rArgType.Elem().Kind() != reflect.Uint8 && !isValuer { + if arg != nil && rArgType.Kind() == reflect.Slice && rArgType.Elem().Kind() != reflect.Uint8 && !isValuer { if rArg.Len() > 0 { tempMarks := make([]string, 0, rArg.Len()) for i := 0; i < rArg.Len(); i++ {