From b054f235b9bf29f2e6ba7c0fe48e41509639c5cd Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Mon, 15 Feb 2016 19:42:49 +0800 Subject: [PATCH] Fix query with extra option --- callback_query.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/callback_query.go b/callback_query.go index 0221c322..11f8b476 100644 --- a/callback_query.go +++ b/callback_query.go @@ -51,13 +51,12 @@ func queryCallback(scope *Scope) { scope.prepareQuerySql() if !scope.HasError() { - var extraOption string - if str, ok := scope.Get("gorm:query_option"); ok { - extraOption = fmt.Sprint(str) - } scope.db.RowsAffected = 0 + if str, ok := scope.Get("gorm:query_option"); ok { + scope.Sql += addExtraSpaceIfExist(fmt.Sprint(str)) + } - if rows, err := scope.SqlDB().Query(scope.Sql+addExtraSpaceIfExist(extraOption), scope.SqlVars...); scope.Err(err) == nil { + if rows, err := scope.SqlDB().Query(scope.Sql, scope.SqlVars...); scope.Err(err) == nil { defer rows.Close() columns, _ := rows.Columns()