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()