mirror of https://github.com/go-gorm/gorm.git
Improve compatibility when set model
This commit is contained in:
parent
32dcacc70b
commit
600d8e7277
|
@ -404,20 +404,20 @@ func TestOrderAndPluck(t *testing.T) {
|
|||
}
|
||||
|
||||
var ages1, ages2 []int64
|
||||
db.Model(&[]User{}).Order("age desc").Pluck("age", &ages1).Order("age").Pluck("age", &ages2)
|
||||
db.Model([]User{}).Order("age desc").Pluck("age", &ages1).Order("age").Pluck("age", &ages2)
|
||||
if !reflect.DeepEqual(ages1, ages2) {
|
||||
t.Errorf("The first order is the primary order")
|
||||
}
|
||||
|
||||
var ages3, ages4 []int64
|
||||
db.Model(&[]User{}).Order("age desc").Pluck("age", &ages3).Order("age", true).Pluck("age", &ages4)
|
||||
db.Model(&User{}).Order("age desc").Pluck("age", &ages3).Order("age", true).Pluck("age", &ages4)
|
||||
if reflect.DeepEqual(ages3, ages4) {
|
||||
t.Errorf("Reorder should works well")
|
||||
}
|
||||
|
||||
ages = []int64{}
|
||||
var names []string
|
||||
db.Model(&User{}).Order("name").Order("age desc").Pluck("age", &ages).Pluck("name", &names)
|
||||
db.Model(User{}).Order("name").Order("age desc").Pluck("age", &ages).Pluck("name", &names)
|
||||
if !(names[0] == "1" && names[2] == "3" && names[3] == "3" && ages[2] == 24 && ages[3] == 22) {
|
||||
t.Errorf("Should be ordered correctly with multiple orders")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue