1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-21 21:30:54 +00:00
This commit is contained in:
Anker Jam 2020-08-11 00:06:36 +08:00
parent 882f1273c8
commit f8c0e6fec5
2 changed files with 6 additions and 6 deletions

View File

@ -387,8 +387,8 @@ type Index struct {
Id int `orm:"column(id)"` Id int `orm:"column(id)"`
// Other Fields // Other Fields
F1 int `orm:"column(f1);unique"` F1 int `orm:"column(f1);index"`
F2 int `orm:"column(f2);unique"` F2 int `orm:"column(f2);index"`
} }
func NewInLine() *InLine { func NewInLine() *InLine {

View File

@ -812,13 +812,13 @@ func TestSpecifyIndex(t *testing.T) {
_, _ = dORM.Insert(index) _, _ = dORM.Insert(index)
throwFailNow(t, AssertIs(index.Id, 2)) throwFailNow(t, AssertIs(index.Id, 2))
_ = dORM.QueryTable(&Index{}).Filter(`f1`, `1`).ForceIndex(`f1`).One(index) _ = dORM.QueryTable(&Index{}).Filter(`f1`, `1`).ForceIndex(`index_f1`).One(index)
throwFailNow(t, AssertIs(index.F2, 2)) throwFailNow(t, AssertIs(index.F2, 2))
_ = dORM.QueryTable(&Index{}).Filter(`f1`, `3`).UseIndex(`f1`, `f2`).One(index) _ = dORM.QueryTable(&Index{}).Filter(`f2`, `4`).UseIndex(`index_f2`).One(index)
throwFailNow(t, AssertIs(index.F2, 4)) throwFailNow(t, AssertIs(index.F1, 3))
_ = dORM.QueryTable(&Index{}).Filter(`f1`, `1`).IgnoreIndex(`f1`, `f2`).One(index) _ = dORM.QueryTable(&Index{}).Filter(`f1`, `1`).IgnoreIndex(`index_f1`, `index_f2`).One(index)
throwFailNow(t, AssertIs(index.F2, 2)) throwFailNow(t, AssertIs(index.F2, 2))
} }