mirror of https://github.com/go-gorm/gorm.git
Fix complicated Select
This commit is contained in:
parent
f07216e90e
commit
e2e417a8c2
|
@ -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")
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue