代码拉取完成,页面将自动刷新
同步操作将从 bigpigeon/toyorm 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
/*
* Copyright 2018. bigpigeon. All rights reserved.
* Use of this source code is governed by a MIT style
* license that can be found in the LICENSE file.
*/
package toyorm
import (
"reflect"
"testing"
)
func TestSearchToExecValue(t *testing.T) {
dialect := DefaultDialect{}
{
model := NewModel(reflect.ValueOf(TestSearchTable{}))
t1 := NewSearchTree(NewSearchBranch(ExprOr)).Fill(
NewSearchTree(NewSearchBranch(ExprAnd)).Fill(
NewSearchTree(NewSearchLeaf(ExprEqual, model.GetFieldWithName("A").ToFieldValue(reflect.ValueOf("22")))),
NewSearchTree(NewSearchLeaf(ExprEqual, model.GetFieldWithName("B").ToFieldValue(reflect.ValueOf("33")))),
),
NewSearchTree(NewSearchBranch(ExprAnd)).Fill(
NewSearchTree(NewSearchLeaf(ExprEqual, model.GetFieldWithName("C").ToFieldValue(reflect.ValueOf("55")))),
NewSearchTree(NewSearchLeaf(ExprEqual, model.GetFieldWithName("D").ToFieldValue(reflect.ValueOf("66")))),
),
)
t.Log(dialect.SearchExec(t1.ToStack()))
}
{
model := NewModel(reflect.ValueOf(TestSearchTable{}))
t2 := NewSearchTree(NewSearchBranch(ExprOr)).Fill(
NewSearchTree(NewSearchBranch(ExprNot)).Fill(
NewSearchTree(NewSearchLeaf(ExprEqual, model.GetFieldWithName("A").ToFieldValue(reflect.ValueOf("22")))),
nil,
),
NewSearchTree(NewSearchBranch(ExprAnd)).Fill(
NewSearchTree(NewSearchLeaf(ExprEqual, model.GetFieldWithName("B").ToFieldValue(reflect.ValueOf("55")))),
NewSearchTree(NewSearchLeaf(ExprEqual, model.GetFieldWithName("C").ToFieldValue(reflect.ValueOf("66")))),
),
)
t2List := t2.ToStack()
t2List = t2List.Condition(model.GetFieldWithName("D").ToFieldValue(reflect.ValueOf("909")), ExprEqual, ExprAnd)
t.Logf("%#v", dialect.SearchExec(t2List))
}
{
model := NewModel(reflect.ValueOf(TestSearchTable{}))
t1 := NewSearchTree(NewSearchBranch(ExprOr)).Fill(
NewSearchTree(NewSearchBranch(ExprAnd)).Fill(
NewSearchTree(NewSearchLeaf(ExprEqual, model.GetFieldWithName("A").ToColumnAlias("t1").ToFieldValue(reflect.ValueOf("22")))),
NewSearchTree(NewSearchLeaf(ExprEqual, model.GetFieldWithName("B").ToColumnAlias("t1").ToFieldValue(reflect.ValueOf("33")))),
),
NewSearchTree(NewSearchBranch(ExprAnd)).Fill(
NewSearchTree(NewSearchLeaf(ExprEqual, model.GetFieldWithName("C").ToColumnAlias("t2").ToFieldValue(reflect.ValueOf("55")))),
NewSearchTree(NewSearchLeaf(ExprEqual, model.GetFieldWithName("D").ToColumnAlias("t2").ToFieldValue(reflect.ValueOf("66")))),
),
)
t.Log(dialect.SearchExec(t1.ToStack()))
t.Logf("%#v\n", t1.ToStack())
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。