mirror of https://github.com/go-gorm/gorm.git
Fix tests for mysql, postgres
This commit is contained in:
parent
84954e6779
commit
1aaac379ae
|
@ -6,7 +6,6 @@ import (
|
|||
|
||||
"github.com/jinzhu/now"
|
||||
|
||||
"math/rand"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
@ -542,11 +541,15 @@ func TestSelectWithEscapedFieldName(t *testing.T) {
|
|||
func TestSelectWithVariables(t *testing.T) {
|
||||
DB.Save(&User{Name: "jinzhu"})
|
||||
|
||||
randomNum := rand.Intn(1000000000)
|
||||
rows, _ := DB.Table("users").Select("? as fake", randomNum).Where("fake = ?", randomNum).Rows()
|
||||
rows, _ := DB.Table("users").Select("? as fake", "name").Rows()
|
||||
|
||||
if !rows.Next() {
|
||||
t.Errorf("Should have returned at least one row")
|
||||
} else {
|
||||
columns, _ := rows.Columns()
|
||||
if !reflect.DeepEqual(columns, []string{"fake"}) {
|
||||
t.Errorf("Should only contains one column")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -152,7 +152,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.AddToVars(arg), 1)
|
||||
str = strings.Replace(str, "?", scope.Dialect().Quote(fmt.Sprintf("%v", arg)), 1)
|
||||
}
|
||||
}
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue