diff --git a/query_test.go b/query_test.go index b15d01ba..580d06c4 100644 --- a/query_test.go +++ b/query_test.go @@ -4,6 +4,7 @@ import ( "fmt" "reflect" + "github.com/jinzhu/gorm" "github.com/jinzhu/now" "testing" @@ -556,7 +557,7 @@ func TestSelectWithEscapedFieldName(t *testing.T) { func TestSelectWithVariables(t *testing.T) { DB.Save(&User{Name: "jinzhu"}) - rows, _ := DB.Table("users").Select("? as fake", "name").Rows() + rows, _ := DB.Table("users").Select("? as fake", gorm.Expr("name")).Rows() if !rows.Next() { t.Errorf("Should have returned at least one row") diff --git a/scope_private.go b/scope_private.go index fdf14dc7..4344f22e 100644 --- a/scope_private.go +++ b/scope_private.go @@ -149,7 +149,7 @@ func (scope *Scope) buildSelectQuery(clause map[string]interface{}) (str string) if valuer, ok := interface{}(arg).(driver.Valuer); ok { arg, _ = valuer.Value() } - str = strings.Replace(str, "?", scope.Dialect().Quote(fmt.Sprintf("%v", arg)), 1) + str = strings.Replace(str, "?", scope.AddToVars(arg), 1) } } return